我将所有内容从 include/git2 带到 /usr/include,然后尝试编译以下程序:
#include <stdio.h>
#include <repository.h>
int main(void) {
puts("Hello, world!");
return 0;
}
当我用 GCC 编译它时,我收到以下错误:
maxwell@UNIX-PC:~$ gcc ok.c
In file included from /usr/include/common.h:16:0,
from /usr/include/repository.h:10,
from ok.c:2:
/usr/include/inttypes.h:33:2: error: #error "Use this header only with Microsoft Visual C++ compilers!"
In file included from /usr/include/inttypes.h:46:0,
from /usr/include/common.h:16,
from /usr/include/repository.h:10,
from ok.c:2:
/usr/include/stdint.h:33:2: error: #error "Use this header only with Microsoft Visual C++ compilers!"
In file included from /usr/include/inttypes.h:46:0,
from /usr/include/common.h:16,
from /usr/include/repository.h:10,
from ok.c:2:
/usr/include/stdint.h:89:30: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int64_t’
/usr/include/stdint.h:90:30: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint64_t’
/usr/include/stdint.h:101:1: error: unknown type name ‘uint64_t’
/usr/include/stdint.h:111:1: error: unknown type name ‘uint64_t’
/usr/include/stdint.h:124:1: error: unknown type name ‘uint64_t’
In file included from /usr/include/common.h:16:0,
from /usr/include/repository.h:10,
from ok.c:2:
/usr/include/inttypes.h:282:1: error: unknown type name ‘_inline’
/usr/include/inttypes.h:284:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__cdecl’
/usr/include/inttypes.h:284:11: error: unknown type name ‘__cdecl’
我看到错误说只能在 Visual Studio 中使用 inttypes.h,那么如何从使用 GCC 编译的程序中调用 repository.h?我真的很想使用 repository.h 中定义的一些数据结构。知道我做错了什么吗?