gcc
apparently cannot find the include file in the specified place. It does work if I use
#include "fullpath/stdint.h"
I can't get it to work using
#include < stdint.h >
I tried compiling a package using gcc
on Mac OS. No success. I nailed the problem to the include file stdint.h
.
I wrote the following test code:
// 1 #include <stdint.h>
// 2 #include "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdint.h"
// 3 typedef unsigned long long uint64_t;
#include <stdio.h>
int main()
{
uint64_t x ;
x = 10 ;
printf("x = %lld\n",x);
}
If I uncomment the first commented out line, labeled as "1", it won't work.
I tried compiling with:
> gcc -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/ test.c
test.c:8:9: error: expected ';' after expression
uint64_t x ;
^
;
test.c:8:1: error: use of undeclared identifier 'uint64_t'
uint64_t x ;
^
I also tried setting the GCC_INCLUDE_DIR
and C_INCLUDE_DIR
environment variables to no avail:
> env | grep INCLUDE C_INCLUDE_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/
GCC_INCLUDE_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/
> gcc test.c
test.c:8:9: error: expected ';' after expression
uint64_t x ;
^
;
test.c:8:1: error: use of undeclared identifier 'uint64_t'
uint64_t x ;
Now, if I use either the 2 or 3 commented out lines the program compiles and runs just fine.
So it must be some problem finding the stdint.h
file. Is there something wrong with my use of -I
? I re-read this line a thousand times, added a space after -I
, took the space out, nothing seems to help. The same happens with the environment variables.
gcc
and Mac OS versions:
> uname -a
Darwin Antonios-MacBook-Pro.local 18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64
> gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin