开发者

Compilation error using eclipse

开发者 https://www.devze.com 2023-03-30 16:22 出处:网络
In the following header file i declared some functions: #ifndef _MY_INT_FUNCTIONS_H_ #define _MY_INT_FUNCTIONS_H_

In the following header file i declared some functions:

    #ifndef _MY_INT_FUNCTIONS_H_
    #define _MY_INT_FUNCTIONS_H_



    int intFcn (const void *key, size_t table_size);
    void intPrint (const void *key);
    int intCompare (const void *key1, const void *key2);


    #endif // _MY_INT_FUNCTIONS_H_

but i get a compi开发者_JAVA百科lation error saying:

"expected declaration specifiers or ‘...’ before ‘size_t’"

regarding the int intFcn function.

im using eclipse INDIGO version.

help anyone?


In C++ size_t is declared in the <cstddef> header in the std namespace.

#include <cstddef>

int intFcn (const void *key, std::size_t table_size);

In C (and in C++ too), it's declared in <stddef.h>:

#include <stddef.h>

int intFcn (const void *key, size_t table_size);


For size_t, you need to :

#include <stddef.h>   // in C

or :

#include <cstddef>    // in C++
0

精彩评论

暂无评论...
验证码 换一张
取 消