编译C库与Visual Studio 2010 [英] Compile a C library with Visual Studio 2010

查看:101
本文介绍了编译C库与Visual Studio 2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来到这里的别人写的,有一个非常好的方式C库编译它在Mac上,并生成一个红宝石包装。

I got here a C library written by someone else, with a very nice way to compile it on a Mac and generate a ruby wrapper.

我在Windows上,我需要生成用于.NET的包装。我知道绝对没有关于C或C ++。

I am on Windows, and I need to generate a wrapper for .Net. I know absolutely nothing about C or C++.


  • 我创建了一个 .I 文件,该文件只是%包含 .H 文件,并使用痛饮生成C#文件和 xxx_wrapper .C 文件。

  • 我已创建了Visual Studio 2010的一个空的C ++项目,并包括所有的 .H .C 该项目的文件(除了那些以生成红宝石包装器)

  • 现在,当我尝试编译,我一次比一次有一个内联函数的几个编译错误:

  • I have created a .i file that just %include the .h file, and used Swig to generate C# files and a xxx_wrapper.c file.
  • I have created an empty C++ project with Visual Studio 2010, and included all the .h and .c files of the project (except the ones to generate the ruby wrapper)
  • Now when I try to compile, I get a few compilation errors each time there is an inline function:

file.c中(54):错误C2054:'('预期的内联后结果
file.c中(54):错误C2085:'swap_img:是不是在正规的参数列表结果
file.c中(54):错误C2143:语法错误:缺少;前{

我已阅读这里,这可能是因为VS试图编译我的C文件为c ++。但我怎么做呢?在code,我不能改变什么(我不会尝试),所以我只需要修复项目。

I have read here that it might be because VS tries to compile my c files as c++. But how do I do that ? I can't change anything in the code (and I wouldn't try), so I just need to "fix" the project.

谢谢!

推荐答案

在该公司由Visual Studio 2010支持C语言的版本,没有字在线。只有C ++有在线。我不认为在线成为,直至C标准(C11)的最新版本的C部分,没有人支持呢。

In the version of the C language that's supported by Visual Studio 2010, there is no word inline. Only C++ has inline. I don't think inline became a part of C until the very latest version of the C standard (C11), which nobody supports yet.

相反,你应该用这个词 __内联,这意味着同样的事情。这里的下划线暗示这是一个延伸的东西,这不是标准C的一部分。

Instead, you should use the word __inline, which means the same thing. The underscores imply that this is an "extension," something that's not part of standard C.

另外,你可以把的#define内嵌__inline 在每个文件的开头,或在 .H 头文件是的#include D开头。这将自动翻译的单词在线 __内联每次出现的时间。

Alternatively, you could put #define inline __inline at the start of each file, or in a .h header file which is #included at the beginning. That would automatically translate the word inline to __inline each time it appears.

(这可能是谁写的人code,采用不同的编译器,其中一个选择添加在线无下划线。它仍然是一个延伸因为它不是标准C的一部分。)

(It's likely that the person who wrote that code was using a different compiler, one which chose to add inline without the underscores. It's still an "extension" because it's not part of Standard C.)

这篇关于编译C库与Visual Studio 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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