本文介绍了编译“hello world"失败带有 Poco 的 Web 服务器应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 Google 上搜索poco 网络服务器示例"时,它提供给我的第一个链接是 这个.现在不可否认,它的星级评分为零,而谷歌提供了一个更官方的例子,来自 Poco 的一个更进一步的例子.尽管如此,该示例非常简单,因此我尝试将其添加到现有 (MFC) 项目中并进行编译.当我这样做时,我收到以下错误:

When I search Google for "poco web server example", the very first link it offers me is this one. Now admittedly it has a zero star rating, and Google offers a more official example from Poco one step down the list. Nonetheless, the example is tantalisingly simple, so I tried to add it to an existing (MFC) project and compile it. When I do, I get these errors:

[...]serverapplication.h(215): error C3646: '_serviceStatus': unknown override specifier
[...]serverapplication.h(215): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
[...]serverapplication.h(216): error C3646: '_serviceStatusHandle': unknown override specifier
[...]serverapplication.h(216): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

serverapplication.h中这两行出现错误:

static SERVICE_STATUS        _serviceStatus; 
static SERVICE_STATUS_HANDLE _serviceStatusHandle; 

当然,即使我所做的只是包含 Poco 头文件而没有其他任何内容,错误仍然存​​在......所以这并不是我的代码有问题,而是我的环境有问题.事实上,如果我用 Poco 自己的 HTTPTimeServer 示例(顺便说一下,作为一个独立项目编译和运行良好)中的更长列表替换 8 个 Poco 头文件 + 3 个 STL 头的列表,我会得到完全相同的错误.

Naturally, the errors persist even when all I do is include the Poco header files and nothing else... so it's not as if my code has a problem, it's more that my environment has a problem. Indeed, I get precisely the same errors if I replace the list of 8 Poco header files + 3 STL headers with the longer list from Poco's own HTTPTimeServer example (which compiles and runs fine as an independent project by the way).

看起来SERVICE_STATUSSERVICE_STATUS_HANDLE 被#defined 定义为什么都没有.是否有编译器设置或预处理器定义可以做到这一点?Poco用户应该注意的陷阱是什么?Poco 和 MFC 之间是否存在兼容性问题?

It looks like SERVICE_STATUS and SERVICE_STATUS_HANDLE are being #defined to nothing at all. Is there a compiler setting or preprocessor definition that would do this? What is the trap that Poco users should beware of falling into? Are there compatibility issues between Poco and MFC?

更新:我可以通过下载 这篇可能相关的文章引用了这个压缩的项目...构建良好...但是当我尝试指定额外的包含文件夹并包含 serverapplication.h 时,就会发生这些错误.Poco ServerApplication 类文档页面上没有提及任何依赖项.>

Update: I can reproduce the issue independently of my application by downloading this zipped project referenced by this potentially relevant article... which builds fine... but the moment I try to specify the extra include folder and include serverapplication.h, these errors occur. There is no mention of any dependencies on the Poco ServerApplication class documentation page.

推荐答案

要在 MFC 项目中包含 POCO 的 ServerApplication.h 头文件,请尝试 #include #include "ServerApplication.h" 之前.请注意,您不得在 MFC 项目中包含 Windows.h,该项目通常会包含 winsvc.h.

To include POCO's ServerApplication.h header file in an MFC project, try #include <winsvc.h> prior to #include "ServerApplication.h". Note that you must not include Windows.h in an MFC project, which would normally include winsvc.h.

这篇关于编译“hello world"失败带有 Poco 的 Web 服务器应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 15:52