Compilation error using eclipse
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++
精彩评论