Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22015

Why for gcc 'UNIX' and 'unix' macros are not the same thing?

$
0
0

I have a weird problem with gcc in Ubuntu Mate.

I need to write a golang program which uses a third-party C library, but i'v run a problem.

When I try to connect the third-party library in this code:

package main// #cgo CFLAGS: -I /opt/cprocsp/include/interfaces/// #cgo CFLAGS: -I /opt/cprocsp/include/// #cgo CFLAGS: -I /opt/cprocsp/include/cpcsp/// #include <stddef.h>// #include "wincspc.h"// #include "wincspc_int.h"import "C"func main() {  var CSPConfig C.CPC_CONFIG  C.CPCGetDefaultConfig(&CSPConfig, nil)  CSPConfig.logConfig.name = string(C.MODNAME)}

I get a compile error:

In file included from /opt/cprocsp/include/cpcsp/wincspc.h:28:0,                 from ./gost.go:7:/opt/cprocsp/include/cpcsp/WinCryptEx.h:35:10: fatal error: wincrypt.h: No such file or directory #include <wincrypt.h>          ^~~~~~~~~~~~compilation terminated.

I didn't know what this error meant. Next I decided to open WinCryptEx.h and I found these lines there:

#if defined UNIX || defined CSP_LITE#include "CSP_WinCrypt.h"#else // UNIX#include <wincrypt.h>#endif // UNIX

So I realized that the compiler runs else statement (but I want it runs if statement because my OS is Linux). To confirm the problem I decided to write a C sample.

#if defined UNIX#include "CSP_WinCrypt.h"#else #include <wincrypt.h>#endif int main(){    printf("Hello world");}

When I try to run this sample, I get the same error.But then I decided to try to run the next code:

#if defined unix#include "CSP_WinCrypt.h"#else #include <wincrypt.h>#endif int main(){    printf("Hello world");}

And it works fine!! The compiler runs if statement as I need.I don't understand why.

I can't change the third-party library. So I need the compiler work correctly with 'UNIX' macro.

Does anyone have a solution? Thanks in advance.


Viewing all articles
Browse latest Browse all 22015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>