无法使用 Poco 编译 "hello world" 网络服务器应用程序
Failure to compile "hello world" web server app with Poco
当我在 Google 中搜索 "poco web server example" 时,它提供给我的第一个 link 是 this one。现在不可否认,它的星级为零,Google 提供了一个来自 Poco 的更官方的例子,在列表中下了一个台阶。尽管如此,该示例非常简单,因此我尝试将其添加到现有 (MFC) 项目中并进行编译。当我这样做时,我得到这些错误:
[...]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 头文件的列表(顺便说一下,它作为一个独立项目编译和运行良好),我会得到完全相同的错误。
看起来 SERVICE_STATUS
和 SERVICE_STATUS_HANDLE
被#defined 什么都没有。是否有可以执行此操作的编译器设置或预处理器定义? Poco用户要谨防掉入的陷阱是什么? Poco和MFC之间是否存在兼容性问题?
更新: 我可以通过下载 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 文档页面独立于我的应用程序重现该问题。
SERVICE_STATUS
是 Windows SDK 中定义的结构。
SERVICE_STATUS structure documentation表示
include Windows.h
你试过#include <Windows.h>
吗?
编辑
由于您正在尝试将其添加到 MFC 应用程序,您是否尝试添加 #include "stdafx.h"
?
要在 MFC 项目中包含 POCO 的 ServerApplication.h
头文件,请在 #include "ServerApplication.h"
之前尝试 #include <winsvc.h>
。请注意,您不得在 MFC 项目中包含 Windows.h
,该项目通常包含 winsvc.h
.
当我在 Google 中搜索 "poco web server example" 时,它提供给我的第一个 link 是 this one。现在不可否认,它的星级为零,Google 提供了一个来自 Poco 的更官方的例子,在列表中下了一个台阶。尽管如此,该示例非常简单,因此我尝试将其添加到现有 (MFC) 项目中并进行编译。当我这样做时,我得到这些错误:
[...]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 头文件的列表(顺便说一下,它作为一个独立项目编译和运行良好),我会得到完全相同的错误。
看起来 SERVICE_STATUS
和 SERVICE_STATUS_HANDLE
被#defined 什么都没有。是否有可以执行此操作的编译器设置或预处理器定义? Poco用户要谨防掉入的陷阱是什么? Poco和MFC之间是否存在兼容性问题?
更新: 我可以通过下载 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 文档页面独立于我的应用程序重现该问题。
SERVICE_STATUS
是 Windows SDK 中定义的结构。
SERVICE_STATUS structure documentation表示
include Windows.h
你试过#include <Windows.h>
吗?
编辑
由于您正在尝试将其添加到 MFC 应用程序,您是否尝试添加 #include "stdafx.h"
?
要在 MFC 项目中包含 POCO 的 ServerApplication.h
头文件,请在 #include "ServerApplication.h"
之前尝试 #include <winsvc.h>
。请注意,您不得在 MFC 项目中包含 Windows.h
,该项目通常包含 winsvc.h
.