1

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?

1

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you, i didn't knew these information before and sorry for not giving enough information. We're both using windows 10 and we compile with Mingw

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.