choubari
choubari

Reputation: 41

Preprocessor: error: missing binary operator before token "("

we're curruntly working on a C project and we've downloaded and used the header dirent.h, the problem is the code was compiled successfully on my teammate laptop but in mine it doesn't compile, telling me this :

    In file included from utils.c:6:0:
dirent.h: In function '_wopendir':
dirent.h:383:28: error: missing binary operator before token "("
 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
                            ^
dirent.h:405:28: error: missing binary operator before token "("
 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
                            ^
dirent.h:413:5: warning: implicit declaration of function 'wcsncpy_s' [-Wimplicit-function-declaration]
     wcsncpy_s (dirp->patt, n+1, dirname, n);
     ^

I searched for the problem and find that it's a preproccessor error and currently on the #if i've tried to add #define WINAPI_FAMILY_PARTITION(Partitions) but it doesn't work.

Please suggest me a solution to compile it successfully, and does the windows version affect on preprocessing?

Upvotes: 1

Views: 1058

Answers (1)

chqrlie
chqrlie

Reputation: 145317

WINAPI_FAMILY_PARTITION is defined in <winapifamily.h>, probably included by <windows.h>. Look at this question for more explanations, but windows intricacies are largely irrelevant for your compilation issue. You might want include <windows.h> before <dirent.h>?

You did not publish the source code for your program, nor did you specify what OS you compile for not what compiler you use, but you mention we've downloaded and used the header dirent.h... This sounds wrong: system include files such as <dirent.h> are automatically installed with the compiler, they are specific to the OS and compiler, you cannot just download one from the net and expect it to work on your system. It might work by chance on your teammate's PC because the OS might be different.

Upvotes: 2

Related Questions