我正在使用 MSVC Ultimate 2012 开发 Windows Server 2008 R2 Standard (SP1)。我正在尝试为 64 位平台编译一个“C”项目(但似乎问题与目标无关)。该项目包含一个 *.pc 文件,该文件必须通过 Pro*C/C++ 预编译器进行预编译。问题是,我无法预编译该文件。解析 windows.h 头文件时预编译失败。请帮忙!!!
更多细节:
1) 源文件:我的my.pc文件开头如下:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <assert.h>
#include <sqlca.h>
#include <sqlcpr.h>
…..
注意:第一个#include <windows.h>
足以用于错误调用。
2) 配置文件:默认pcscfg.cfg文件为空,项目配置文件my.cfg如下:
sys_include=(d:\Progra~1\Micros~2.0\VC\include,c:\Progra~2\WI3CF2~1\8.0\Include\um,c:\Progra~2\WI3CF2~1\8.0\Include\shared,$PROC11_ORACLE_HOME\PRECOMP\PUBLIc)
sqlcheck=full
parse=FULL
define=_WIN64 (or without this line)
注意:d:\Progra~1\Micros~2.0\VC\include = D:\Program Files\Microsoft Visual Studio 10.0\VC\include, c:\Progra~2\WI3CF2~1\8.0\Include\um = C :\Program Files (x86)\Windows Kits\8.0\Include\um, c:\Progra~2\WI3CF2~1\8.0\Include\shared = C:\Program Files (x86)\Windows Kits\8.0\Include\共享,$PROC11_ORACLE_HOME = d:\oracle\product\11.2.0\client_2。这些路径可以找到所有需要的头文件。
3) 命令行:我在自定义构建工具/常规选项中为 my.pc 文件定义了以下命令行:
$(PROC11_ORACLE_HOME)\bin\proc config=.\my.cfg iname=%(Filename).pc oname=.\%(Filename).c include="$(MSDEV_HOME)\vc\include".
注意:$(MSDEV_HOME) = D:\Program Files\Microsoft Visual Studio 10.0.
4) 平台: MSVC 平台设置为 x64,但我在 Win32 上也获得了类似的结果。
5) 错误信息:如果my.cfg文件中涉及define=_WIN64,预编译时收到错误信息:
1> Syntax error at line 46, column 1, file d:\Progra~1\Micros~2.0\VC\include\vadefs.h:
1> Error at line 46, column 1 in file d:\Progra~1\Micros~2.0\VC\include\vadefs.h
1> typedef unsigned __int64 uintptr_t;
1> 1
1> **PCC-S-02201, Encountered the symbol "typedef" when expecting one of the following:**
1> ; , = ( [
1> The symbol ";" was substituted for "typedef" to continue.
6) 错误消息:如果my.cfg 文件中不涉及 define=_WIN64,则在预编译期间收到错误消息:
1> Syntax error at line 48, column 1, file d:\Progra~1\Micros~2.0\VC\include\vadefs.h:
1> Error at line 48, column 1 in file d:\Progra~1\Micros~2.0\VC\include\vadefs.h
1> typedef _W64 unsigned int uintptr_t;
1> 1
1> **PCC-S-02201, Encountered the symbol "typedef" when expecting one of the following:**
1> ; , = ( [
7) 文件 vadefs.h: vadefs.h 头文件中的关键行如下所示:
#ifndef _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t; (this is line no. 46)
#else
typedef _W64 unsigned int uintptr_t; (this is line no. 48)
#endif
#define _UINTPTR_T_DEFINED
#endif
问题是,为什么标准 Microsoft 头文件中的预编译失败。宏中可能有一些混乱,例如与_WIN64 相关的东西?或者我应该在配置文件中添加另一个宏吗?我已经阅读了很多讨论,但没有进展。任何想法将不胜感激!