Login  •  Register


OpcUa Server in MFC app

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

OpcUa Server in MFC app

Postby esanya » 29 Apr 2019, 11:26

Hi,

I'm implementing a OpcUa Server app based on the Unified_Automation OPCUA UaSdkCppBundleSource.

I have to integrate the UaSdkCppBundle into a MFC (VisualStudio 2015) app.

I get a compiler error:

1>c:\program files (x86)\microsoft visual studio 14.0\vc\atlmfc\include\afxv_w32.h(16): fatal error C1189: #error: WINDOWS.H already included. MFC apps must not #include <windows.h>

The include hierarhy looks like this:

1> Note: including file: p:\opcuaserver\source\suddatamanager\suddatamanager.h
1> Note: including file: P:\OpcUaServer\Source\OpcUaServer\stdafx.h
1> Note: including file: p:\opcuaserver\source\opcuaserver\targetver.h
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include\afxwin.h
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include\afx.h
1> Note: including file: C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\new.h
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\crtdefs.h
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\vcruntime.h
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include\afxver_.h
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include\afxv_w32.h
1>c:\program files (x86)\microsoft visual studio 14.0\vc\atlmfc\include\afxv_w32.h(16): fatal error C1189: #error: WINDOWS.H already included. MFC apps must not #include <windows.h>
1> datachangesimulator.cpp

So if I understand correctly:

MFC apps must not #include <windows.h>

Opcua includes header files which require windows.h.

How to resolve this?

Thanks,
Regards,
Sandor
esanya
Newbie
Newbie
 
Posts: 1
Joined: 29 Apr 2019, 10:21

Re: OpcUa Server in MFC app

Postby stefanmix » 29 May 2019, 10:30

I had the same issue. The point is that you need to keep MFC and UA strictly seperated. I created an interface class that encapsulates the MFC part. This interface must of course not use any MFC type, e.g. use std::string, not CString.
In the non MFC part i use a forward declaration to access that interface class. This ensures no MFC headerfiles drop in which again would brake the compilation.
stefanmix
Newbie
Newbie
 
Posts: 1
Joined: 04 Sep 2017, 14:18


Return to C++ based OPC UA SDK

Who is online

Users browsing this forum: No registered users and 0 guests