Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C1189 error : MFC requires C++ compilation (use a .cpp suffix)

1,586 views
Skip to first unread message

vinokuax

unread,
Jan 23, 2005, 7:47:02 PM1/23/05
to
I converted an existing MFC application into ATL project with MFC support.
I also checked an option to build stubless proxy.
When I compile it I am getting the following error in Afx.h file:

...
Compiling...
Coots_i.c
dlldatax.c
c:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\afx.h(15) :
fatal error C1189: #error : MFC requires C++ compilation (use a .cpp suffix)

Please advise.
Thank you,
Alex.

Frank Hickman [MVP]

unread,
Jan 23, 2005, 10:02:17 PM1/23/05
to
"vinokuax" <vino...@discussions.microsoft.com> wrote in message
news:78DBCE6B-050F-49D7...@microsoft.com...

Your .c extension is causing the C compiler to be invoked. ATL requires the
C++ compiler. You can change the extensions of your source files and tell
the C++ compiler that the functions are C by wrapping the function
declarations with

extern "C"
{
void MyFunctions( void );
...
}

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.

vinokuax

unread,
Jan 24, 2005, 10:19:02 AM1/24/05
to
Thank you for your response Frank.

Dlldatax.c and dlldatax.h files are the files that get generated when you
create ATL Project with the option "Merge Proxy/Stub" checked. When you add a
Simple ATL Object to this project you can compile it just fine. On the other
hand when I use these files with my project I am getting the error that I
previously mentioned.

Here is the contents of dlldatax.h file:
===============================================
#pragma once

#ifdef _MERGE_PROXYSTUB

extern "C"
{
BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason,
LPVOID lpReserved);
STDAPI PrxDllCanUnloadNow(void);
STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
STDAPI PrxDllRegisterServer(void);
STDAPI PrxDllUnregisterServer(void);
}

#endif
=================================================

Here is the contents of dlldatax.c file:
=================================================
// wrapper for dlldata.c
#include "StdAfxAtl.h"

#ifdef _MERGE_PROXYSTUB // merge proxy stub DLL

#define REGISTER_PROXY_DLL //DllRegisterServer, etc.

#define _WIN32_WINNT 0x0500 //for WinNT 4.0 or Win95 with DCOM
#define USE_STUBLESS_PROXY //defined only with MIDL switch /Oicf

#pragma comment(lib, "rpcns4.lib")
#pragma comment(lib, "rpcrt4.lib")

#define ENTRY_PREFIX Prx

#include "dlldata.c"
#include "Coots_p.c"

#endif //_MERGE_PROXYSTUB
=================================================

Coots_i.c, Coots_p.c and dlldata.c files are always generated when you
compile this project.

Please help.
Thank you,
Alex.

Frank Hickman [MVP]

unread,
Jan 24, 2005, 11:42:26 AM1/24/05
to
"vinokuax" <vino...@discussions.microsoft.com> wrote in message
news:64BED4FD-B0F7-4FA3...@microsoft.com...

> Thank you for your response Frank.
>
> Dlldatax.c and dlldatax.h files are the files that get generated when you
> create ATL Project with the option "Merge Proxy/Stub" checked. When you
> add a
> Simple ATL Object to this project you can compile it just fine. On the
> other
> hand when I use these files with my project I am getting the error that I
> previously mentioned.
>

<snip>

Your last sentence there implies that your project was originally created as
MFC and your attempting to convert it to use ATL by using these files. Is
that correct? What does your stdafx.h file have in it?

vinokuax

unread,
Jan 24, 2005, 12:11:02 PM1/24/05
to
That is correct. I am converting old MFC app to ATL.
Here is my StdAfx.h file:

==================================================
#pragma once

//#ifndef STRICT
//#define STRICT
//#endif

#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif

// Modify the following defines if you have to target a platform prior to
the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different
platforms.
#ifndef WINVER // Allow use of features specific to Windows 95 and
Windows NT 4 or later.
#define WINVER 0x0400 // Change this to the appropriate value to target
Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or
later.
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to
target Windows 2000 or later.
#endif

#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or
later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to
target Windows Me or later.
#endif

#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target
IE 5.0 or later.
#endif

#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE

//#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors
will be explicit

#include <afxwin.h> // MFC core and standard components
#include <afxdisp.h>

//#include <afxctl.h> // MFC support for ActiveX Controls
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Comon Controls
#endif

#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxdb.h>
#include <afxole.h>
#include <afxtempl.h>
#include <afxpriv.h>


#include <math.h>
#include "datatype.h"

#import <msxml3.dll>
using namespace MSXML2;

#include <atlbase.h>
#include <atlcom.h>
using namespace ATL;

//#import "ICBSSignOn.tlb" no_namespace named_guids
#import "ICBSSignon.tlb" no_auto_exclude rename_namespace("X") named_guids

=====================================================

I also tried to use this StdAfx.h file with a simple ATL project and it
compiles fine.

Thank you,
Alex.

Arnaud Debaene

unread,
Jan 24, 2005, 1:23:25 PM1/24/05
to
vinokuax wrote:
> Thank you for your response Frank.
>
> Dlldatax.c and dlldatax.h files are the files that get generated when
> you create ATL Project with the option "Merge Proxy/Stub" checked.
> When you add a Simple ATL Object to this project you can compile it
> just fine. On the other hand when I use these files with my project I
> am getting the error that I previously mentioned.

Add /TP to the compiler flags, to force compilation as C++

Arnaud
MVP - VC


vinokuax

unread,
Jan 24, 2005, 2:23:06 PM1/24/05
to
I already have /TP flag set at the project level.
I assume that you are suggesting to set this flag for dlldatax.c file.
When I do so I am getting following errors in RpcProxy.h file in PlatformSDK:

Compiling...
dlldatax.c
c:\BranchTeller\Release 4.2.6 POC\Source\Coots\dlldatax.c(8) : warning
C4005: '_WIN32_WINNT' : macro redefinition
c:\BranchTeller\Release 4.2.6 POC\Source\Coots\StdAfx.h(23) : see
previous definition of '_WIN32_WINNT'


c:\Program Files\Microsoft Visual Studio

8\VC\PlatformSDK\Include\RpcProxy.h(175) : error C2146: syntax error :
missing ';' before identifier 'Vtbl'


c:\Program Files\Microsoft Visual Studio

8\VC\PlatformSDK\Include\RpcProxy.h(175) : error C2501:
'tagCInterfaceStubVtbl::IRpcStubBufferVtbl' : missing storage-class or type
specifiers


c:\Program Files\Microsoft Visual Studio

8\VC\PlatformSDK\Include\RpcProxy.h(175) : error C2501:
'tagCInterfaceStubVtbl::Vtbl' : missing storage-class or type specifiers


c:\Program Files\Microsoft Visual Studio

8\VC\PlatformSDK\Include\RpcProxy.h(192) : error C2143: syntax error :
missing ';' before '*'


c:\Program Files\Microsoft Visual Studio

8\VC\PlatformSDK\Include\RpcProxy.h(192) : error C2501:
'tagCStdPSFactoryBuffer::lpVtbl' : missing storage-class or type specifiers
c:\BranchTeller\Release 4.2.6 POC\Source\Coots\dlldata.c(32) : error C2556:
'void _purecall(void)' : overloaded function differs only by return type from
'int _purecall(void)'
c:\BranchTeller\Release 4.2.6 POC\Source\Coots\dlldata.c(32) : error C2371:
'_purecall' : redefinition; different basic types
c:\BranchTeller\Release 4.2.6 POC\Source\Coots\Coots_p.c(189) : error C2440:
'initializing' : cannot convert from 'unsigned long (__stdcall *)(unsigned
long *,unsigned long,BSTR *)' to 'USER_MARSHAL_SIZING_ROUTINE'
None of the functions with this name in scope match the target type
c:\BranchTeller\Release 4.2.6 POC\Source\Coots\Coots_p.c(190) : error C2440:
'initializing' : cannot convert from 'unsigned char *(__stdcall *)(unsigned
long *,unsigned char *,BSTR *)' to 'USER_MARSHAL_MARSHALLING_ROUTINE'
None of the functions with this name in scope match the target type
c:\BranchTeller\Release 4.2.6 POC\Source\Coots\Coots_p.c(191) : error C2440:
'initializing' : cannot convert from 'unsigned char *(__stdcall *)(unsigned
long *,unsigned char *,BSTR *)' to 'USER_MARSHAL_UNMARSHALLING_ROUTINE'
None of the functions with this name in scope match the target type
c:\BranchTeller\Release 4.2.6 POC\Source\Coots\Coots_p.c(192) : error C2440:
'initializing' : cannot convert from 'void (__stdcall *)(unsigned long *,BSTR
*)' to 'USER_MARSHAL_FREEING_ROUTINE'
None of the functions with this name in scope match the target type
c:\BranchTeller\Release 4.2.6 POC\Source\Coots\Coots_p.c(262) : error C2440:
'initializing' : cannot convert from 'long (__stdcall *)(IRpcStubBuffer
*,IRpcChannelBuffer *,PRPC_MESSAGE,unsigned long *)' to 'const
PRPC_STUB_FUNCTION'
None of the functions with this name in scope match the target type
c:\BranchTeller\Release 4.2.6 POC\Source\Coots\Coots_p.c(270) : error C2078:
too many initializers

Frank Hickman [MVP]

unread,
Jan 24, 2005, 4:49:00 PM1/24/05
to
"vinokuax" <vino...@discussions.microsoft.com> wrote in message
news:EC82767A-4E50-4FC5...@microsoft.com...

> That is correct. I am converting old MFC app to ATL.
> Here is my StdAfx.h file:
>

<snip>

I think your best bet would be to start a new ATL project that supports MFC
and move your other project files to it. I say this because when you create
projects, the project file gets specific flags set that tell nmake to do
certain things. ATL and MFC may seem like simple projects however the
project files are more complicated. If you create a bare bones ATL project
that supports MFC you can compare the differences in settings and switches
and merge the two but I think it would be easier to just move the source
files to the new project.

0 new messages