如何从libgit2使用C头文件而不会出现此错误? [英] How do I use C headers from libgit2 without getting this error?

查看:363
本文介绍了如何从libgit2使用C头文件而不会出现此错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  #include<< p>< ; stdio.h中> 
#include< repository.h>

int main(void){
puts(Hello,world!);
返回0;
}

当我使用GCC进行编译时,出现以下错误:

  maxwell @ UNIX-PC:〜$ gcc ok.c 
从/usr/include/common.h包含的文件中: 16:0,从/usr/include/repository.h:10获得
,从ok.c获得
:2:
/usr/include/inttypes.h:33:2:error: #error仅在Microsoft Visual C ++编译器中使用此标题!
在/usr/include/inttypes.h:46:0包含的文件中,/usr/include/common.h:16包含
,从/usr/include/repository.h包含
:10,从ok.c中获得
:2:
/usr/include/stdint.h:33:2:error:#error仅在Microsoft Visual C ++编译器中使用此标头!
在/usr/include/inttypes.h:46:0包含的文件中,/usr/include/common.h:16包含
,从/usr/include/repository.h包含
:10,来自ok.c的
:2:
/usr/include/stdint.h:89:30:error:expected'=',',',';','asm'或在'int64_t'之前'__attribute__'
/usr/include/stdint.h:90:30:error'expected'=',',';','asm'或'__attribute__''uint64_t'之前'
/usr/include/stdint.h:101:1:错误:未知类型名称'uint64_t'
/usr/include/stdint.h:111:1:错误:未知类型名称'uint64_t'
/usr/include/stdint.h:124:1:错误:未知类型名称'uint64_t'
在/usr/include/common.h:16:0包含的文件中,
from /usr/include/repository.h:10,来自ok.c的
:2:
/usr/include/inttypes.h:282:1:错误:unknown type name'_inline'
/usr/include/inttypes.h:284:11:error:expected'=',',',';','asm'o '__cdecl'之前的'__attribute__'
/usr/include/inttypes.h:284:11:error:unknown type name'__cdecl'

我发现只有在Visual Studio中才使用inttypes.h的错误,那么如何从使用GCC编译的程序调用repository.h?我真的想使用repository.h中定义的一些数据结构。任何想法我做错了什么?

解决方案

为了记录,您应该使用构建系统来安装标题。这些头文件并不包含在内。如果你想使用libgit2,你应该包含 git2.h


I took everything from include/git2 to /usr/include, then tried compiling the following program:

#include <stdio.h>
#include <repository.h>

int main(void) {
    puts("Hello, world!");
    return 0;
}

When I compile this with GCC, I get the following error:

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’

I see the error that says only to use inttypes.h only with Visual Studio, so how do I call repository.h from a program compiled with GCC? I really want to use some data structures defined in repository.h. Any idea what I am doing wrong?

解决方案

For the record, you should use the build system to install the headers. These headers aren't made to be included themselves. If you want to use libgit2, you should include git2.h.

这篇关于如何从libgit2使用C头文件而不会出现此错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆