C++ sqlucode.h 标头的 ODBC 问题

发布于 2024-07-17 04:43:25 字数 518 浏览 3 评论 0原文

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

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

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

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

我的项目中的任何地方都没有 sqlucdode.h 的 #include,但它仍然将声明解析为 sqlucdode.h 中的声明。 我怎样才能防止这种情况发生? 谢谢。

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

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.

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.

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤檠 2024-07-24 04:43:25

似乎您遇到了预处理器问题而不是链接问题。

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

如果您使用的是早期版本的 Visual Studio,您仍然可以通过将 UNICODE_UNICODE 的预处理器定义更改为 _MBCS 来修复它 - 这只是您的问题必须自己找到它们。

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

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.

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文