头文件错误......... [英] Header File Error.........

查看:73
本文介绍了头文件错误.........的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我写了几个头文件,但是所有这些文件都有类似的错误。你能帮帮我吗?



这是头文件:

Hello guys,

i wrote a few header files, but all of them give similiar errors. Can you help me ?

Here is the header file:

#ifndef insertion_sort
#define insertion_sort
    void insertion_sort(int array[], int array_SIZE);

    void insertion_sort(int array[], int array_SIZE){
        int i, j, carry;
            for(i=1; i<array_size>< i++){
                carry=array[i];
                j=i;
                    while(j>0 && array[j-1]>carry){
                        array[j]=array[j-1];
                        j--;
                    }
                array[j]=carry;
            }
    }

#endif // insertion_sort



并且有错误:



函数原型和函数定义给出相同的错误。



在int之前预期的非限定id;

预期')'在'int'之前


and there is the errors:

function prototype and function definitions are giving same errors.

expected unqualified-id before int;
expected ')' before 'int'

推荐答案

你不应该使用你的函数的名称或class包含头文件的 #define 。行 #define insertion_sort 告诉预处理器用空字符串替换所有出现的 insertion_sort 并导致奇怪的错误消息。



尝试使用
You should not use the name of your function or class as the #define that wraps the header file. The line "#define insertion_sort" is telling the preprocessor to replace all the occurrences of "insertion_sort" with an empty string and causing the strange error messages.

Try using
#ifndef insertion_sort_h
#define insertion_sort_h

相反,如果您使用的是Visual C ++,则可以使用

instead, or if you're using Visual C++ you could use

#pragma once

而不是保护定义。


这篇关于头文件错误.........的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆