c - 如何设置 Visual Studio 以理解 GCC 定义?

标签 c visual-studio visual-studio-2010

我有一个 C 语言的项目,在头文件中定义了以下代码,

/*_INLINE_ define for abstraction of the keyword inline*/
#define INLINE    __inline__

我已经使用 GCC 为 Tricore 微 Controller 编译了项目,现在我必须使用 Visual Studio 2010 编译相同的项目以进行模拟。

但 Visual Studio 编译器显示以下错误:

error C2054: expected '(' to follow '__inline__' 

如何设置 Visual Studio 来理解这个定义?

最佳答案

__inline__ 是一个 GCC-specific keyword ,不是宏。您需要做的是找出与该关键字等效的 MSVC,并根据正在运行的编译器更改宏 INLINE 的内容。

MS docs似乎表明关键字的 MSVC 再现将是 __inline。因此,您应该像这样修改标题:

#ifdef __GNUC__
  #define INLINE __inline__
#elif defined _MSC_VER
  #define INLINE __inline
#else
  // Some kind of default, or error out
#endif

关于c - 如何设置 Visual Studio 以理解 GCC 定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48986213/

相关文章:

c# - (如何)调试会改变程序的工作流程?

c - 在c中嵌入lua代码

c++ - 调试到 MFC header 代码不适用于 Visual Studio 2019

c# - 如何确定项目/解决方案中哪些代码最常被使用?

c# - 在 Microsoft Visual Studio 调试器中更改日期时间

visual-studio-2010 - 如何在 C# 中创建 COM 可见类?

c - 了解 printf 吗?

c - 在 C 中从本地时间(没有 Boost!)获取毫秒数

c - 我正在使用 DOS,我正在尝试将背景设为白色

wpf - wpf 中的比例大小