sqlucode.h头文件的C ++ ODBC问题

时间:2021-04-14 04:31:31

I found a great C++/ODBC example here...

我在这里发现了一个很棒的C ++ / ODBC示例......

The project I downloaded builds great and everything works. However, when I copy the .cpp and .h files into another project, I seem to have a linking problem.

我下载的项目构建很棒,一切正常。但是,当我将.cpp和.h文件复制到另一个项目时,我似乎有一个链接问题。

The SQLConnect function in sql.h is the one I want. When I right-click this function in the easyodbc.h file in the project I downloaded, it jumps to the declaration in sql.h. Life is good.

sql.h中的SQLConnect函数是我想要的。当我在我下载的项目中的easyodbc.h文件中右键单击此函数时,它会跳转到sql.h中的声明。生活很好。

However, in the project I created, when I do this it jumps to a UNICODE definition in sqlucode.h. This seems to be causing problems and my test project crashes.

但是,在我创建的项目中,当我这样做时,它跳转到sqlucode.h中的UNICODE定义。这似乎导致了问题,我的测试项目崩溃了。

I don't have an #include for sqlucdode.h anywhere in my project, yet it still resolves the declaration to the one in sqlucode.h. How can I prevent this? Thanks.

我的项目中没有sqlucdode.h的#include,但它仍然将声明解析为sqlucode.h中的声明。我怎么能阻止这个?谢谢。

1 个解决方案

#1


Seems like you have a preprocessor problem rather than a linking problem.

好像你有预处理器问题而不是链接问题。

You probably have a preprocessor definition for UNICODE (or _UNICODE) in your project file. In Visual C++ 2005 and 2008 you can fix this by going to your project properties and changing Character Set from Use Unicode Character Set to Use Multi-Byte Character Set. When you apply this setting, Visual Studio fixes up the right preprocessor and linker settings for you.

您可能在项目文件中有UNICODE(或_UNICODE)的预处理器定义。在Visual C ++ 2005和2008中,您可以通过转到项目属性并将“使用Unicode字符集”中的“字符集”更改为“使用多字节字符集”来解决此问题。应用此设置时,Visual Studio会为您修复正确的预处理器和链接器设置。

If you have an earlier version of Visual Studio you can still fix it by changing the preprocessor definitions for UNICODE and _UNICODE to _MBCS - it's just you'll have to find them yourself.

如果您有Visual Studio的早期版本,您仍然可以通过将UNICODE和_UNICODE的预处理器定义更改为_MBCS来修复它 - 您只需要自己找到它们。

EDIT: I just downloaded that example code and tried it - good news, it's exactly as I guessed, change to a multibyte character set and you'll be fine.

编辑:我刚刚下载了示例代码并尝试了 - 好消息,正如我猜测的那样,更改为多字节字符集,你会没事的。

#1


Seems like you have a preprocessor problem rather than a linking problem.

好像你有预处理器问题而不是链接问题。

You probably have a preprocessor definition for UNICODE (or _UNICODE) in your project file. In Visual C++ 2005 and 2008 you can fix this by going to your project properties and changing Character Set from Use Unicode Character Set to Use Multi-Byte Character Set. When you apply this setting, Visual Studio fixes up the right preprocessor and linker settings for you.

您可能在项目文件中有UNICODE(或_UNICODE)的预处理器定义。在Visual C ++ 2005和2008中,您可以通过转到项目属性并将“使用Unicode字符集”中的“字符集”更改为“使用多字节字符集”来解决此问题。应用此设置时,Visual Studio会为您修复正确的预处理器和链接器设置。

If you have an earlier version of Visual Studio you can still fix it by changing the preprocessor definitions for UNICODE and _UNICODE to _MBCS - it's just you'll have to find them yourself.

如果您有Visual Studio的早期版本,您仍然可以通过将UNICODE和_UNICODE的预处理器定义更改为_MBCS来修复它 - 您只需要自己找到它们。

EDIT: I just downloaded that example code and tried it - good news, it's exactly as I guessed, change to a multibyte character set and you'll be fine.

编辑:我刚刚下载了示例代码并尝试了 - 好消息,正如我猜测的那样,更改为多字节字符集,你会没事的。