Itzik984
Itzik984

Reputation: 16804

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 compilation error saying:

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

regarding the int intFcn function.

im using eclipse INDIGO version.

help anyone?

Upvotes: 1

Views: 2353

Answers (2)

Sander De Dycker
Sander De Dycker

Reputation: 16243

For size_t, you need to :

#include <stddef.h>   // in C

or :

#include <cstddef>    // in C++

Upvotes: 4

R. Martinho Fernandes
R. Martinho Fernandes

Reputation: 234654

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);

Upvotes: 4

Related Questions