473,320 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Compiler warning with C++/CLI & ON_BN_CLICKED

dan
I am trying to port a legacy MFC application to C++/CLI. I have
managed to build the code under VS 2008 and I am in the process of
enabling the /CLR compiler directive. My goal is to try and convert
the application to a series of Mixed assemblies that will run
under .NET.

The application makes use of Message Maps using standard MFC
conventions.

I have noticed that any Message Maps using the ON_BN_CLICKED header
directive leads to the compiler warning

C4793 function compiled as native non-clr call vcall thunks must be
compiled as native

ON_BN_CLICKED is defined as ON_CONTROL( BN_CLICKED, id, memberFxn )

and ON_CONTROL( BN_CLICKED, id, memberFxn ) reduces to

{WM_COMMAND, (WORD) wNotifyCode, (WORD) id, (WORD) id, AfxSigCmd_v,
(static_cast< AFX_PMSG (memberFxn)) },

So there must be an issue with .NET and the WM_COMMAND statement. Is
there a stanard way to replace ON_BN_CLICKED in a .NET friendly manner
so that I can compile my ON_BN_CLICKED messag maps in C++/CLI without
the compiler warning.

Sep 16 '08 #1
4 4888
Hi dan!
I am trying to port a legacy MFC application to C++/CLI. I have
managed to build the code under VS 2008 and I am in the process of
enabling the /CLR compiler directive. My goal is to try and convert
the application to a series of Mixed assemblies that will run
under .NET.
I suggest to enable /clr just to specific files, which needs this feature.
C4793 function compiled as native non-clr call vcall thunks must be
compiled as native
As the _warning_ says:
(Some) virtual functions must be compiled as native...

So there must be an issue with .NET and the WM_COMMAND statement. Is
there a stanard way to replace ON_BN_CLICKED in a .NET friendly manner
so that I can compile my ON_BN_CLICKED messag maps in C++/CLI without
the compiler warning.
Disable /clr for this file.

Greetings
Jochen
Sep 17 '08 #2
dan
On Sep 17, 1:39*am, "Jochen Kalmbach [MVP]" <nospam-
Jochen.Kalmb...@holzma.dewrote:
Hi dan!
I am trying to port a legacy MFC application to C++/CLI. I have
managed to build the code under VS 2008 and I am in the process of
enabling the /CLR compiler directive. My goal is to try and convert
the application to a series of Mixed assemblies that will run
under .NET.

I suggest to enable /clr just to specific files, which needs this feature..
C4793 function compiled as native non-clr call vcall thunks must be
compiled as native

As the _warning_ says:
(Some) virtual functions must be compiled as native...
So there must be an issue with .NET and the WM_COMMAND statement. Is
there a stanard way to replace ON_BN_CLICKED in a .NET friendly manner
so that I can compile my ON_BN_CLICKED messag maps in C++/CLI without
the compiler warning.

Disable /clr for this file.

Greetings
* *Jochen
Disabling /clr for each file with an ON_BN_CLICKED would remove a
significant percentage of the files in my app, so I do not think it is
an option.

I doubt that the C++/CLI would ship with a bug of this size.
ON_BN_CLICKED is very common in MFC.

Either I am using some unusual combination of old header files that
are doing something non-standard or there is something about my
project configuration that leads to the compiler warning.

I guess the next step is to build a small MFC app that calls
ON_BN_CLICKED in a message map. If I can get that app in C++/CLI, I
will try and figure out the difference between the example and my
application. Otherwise, there is a C++/CLI bug.

Dan




Sep 18 '08 #3
You've got something else going on.

A new MFC project compiled entirely managed (/CLR turned on at project
settings) builds with no warnings.
That includes adding virtual overrides like OnOK, OnCancel, and
ON_BN_CLICKED message map entries.

You may want to try creating a project with the wizard then compare it's
header file #includes and project settings with yours and see what you're
doing differently.

Mark

--
Mark Salsbery
Microsoft MVP - Visual C++

Sep 24 '08 #4
<da*@6noels.comwrote in message
news:53**********************************@w7g2000h sa.googlegroups.com...
On Sep 17, 1:39 am, "Jochen Kalmbach [MVP]" <nospam-
Jochen.Kalmb...@holzma.dewrote:
>Hi dan!
Disabling /clr for each file with an ON_BN_CLICKED would remove a
significant percentage of the files in my app, so I do not think it is
an option.
Disabling /CLR doesn't remove a file from the project.

In fact, you can use #pragma managed/#pragma unmanaged to control
managed/unmanaged compilation down to a per-function level.

I doubt that the C++/CLI would ship with a bug of this size.
ON_BN_CLICKED is very common in MFC.
I agree.

There's no bug that I'm aware of (see my other reply). I've been using MFC
code compiled managed since VS 2003 .NET without compiler warnings.

Mark

--
Mark Salsbery
Microsoft MVP - Visual C++

Sep 24 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Sony Antony | last post by:
I have the following simple program in Solaris Forte compiler 5.4 producing the warning. Though it produces the warning, it works fine as expected. This has been compiling fine without any...
0
by: Kenneth Gomez | last post by:
Hello, I have tried many avenues (web search, borland website, libxml website) before deciding to post here. I'm trying to install libxml2 on windows ME to work with my Borland C++ 5 Compiler...
1
by: Hafeez | last post by:
I am having real trouble compiling this code http://www.cs.wisc.edu/~vganti/birchcode/codeHier/AttrProj.tgz The attachment shows errors when compiled using the current version of g++ in a...
14
by: Jinesh | last post by:
Dear Guru's: Have a simple C questions. Is this a bug or am I doing something reallllly stupid? Here's the code snippet:- ---------------------------Code------------------------------...
29
by: junky_fellow | last post by:
Consider the following piece of code: struct junk { int i_val; int i_val1; char c_val; }; int main(void) {
5
by: rawCoder | last post by:
Hi All, In Visual Basic .NET , your function definition might requirre you to return a value but (accidently/intentionally) you dont put any 'return value' in the function. In this case VB...
34
by: Bob | last post by:
Hi, The compiler gives Warning 96 Variable 'cmdSource' is used before it has been assigned a value. A null reference exception could result at runtime. Dim cmdSource as SQlClient.SQLDataReader...
1
by: mjobbe | last post by:
I have an installer that requires three merge modules (ATL, CRT, and MFC), and after adding them in, I get the following warnings when I build the MSI: WARNING: Two or more objects have the same...
3
by: gil | last post by:
Hi, I'm trying to find the best way to work with compiler warnings. I'd like to remove *all* warnings from the code, and playing around with the warning level, I've noticed that compiling with...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.