dirent.h,unistd.h, pthread.h specific error in vs2019 native compiler

PANDEY Manish 21 Reputation points
2021-09-30T11:00:00.533+00:00

Hi Team,

I am writing C api for both windows and linux. Gcc specific below header files are giving issue in VS 2019.
dirent.h,unistd.h, pthread.h.

What is the best possible way to overcome this issue in vs2019 native compiler.
My api is in C.
Please do let me know in case any further details are required.

Regards
Manish

Developer technologies | Visual Studio | Debugging
Developer technologies | Visual Studio | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 122.7K Reputation points
    2021-10-05T08:05:12.287+00:00

    Maybe you can use the standard library (STL) or other libraries, such as BOOST.

    You can also detect the compilation environment and select the specific code using the #if or #ifdef, for example:

    #ifdef _MSC_VER
       // Visual Studio
       . . .
    #else
    #ifdef __GNUC__
       // GCC 
       . . .
    #endif
    #endif
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.