Solved

Contamination from unmanaged code in managed VC++.NET

Posted on 2004-08-12
8
873 Views
Last Modified: 2013-12-03
I am trying to merge a code which was translated from unmanaged to managed VC++.NET with another piece of code which was managed to begin with. Each one of these codes compiles fine. However, when I merge them unexpected errors show up. For instance, in the merged code I have explicitly written:

windir = System::Environment::GetEnvironmentVariable("windir");

However, I receive the following error:

Form1.h(37): error C2039: 'GetEnvironmentVariableA' : is not a member of 'System::Environment'

'GetEnvironmentVariableA' is nowhere to be found in my merged code unless some #include invokes it from somewhere and makes it replace what I actually have in the merged code. What might be the reason for all that?
0
Comment
Question by:judico
  • 4
  • 4
8 Comments
 
LVL 16

Expert Comment

by:nonubik
ID: 11784594
GetEnvironmentVariable is a macro for GetEnvironmentVariableA or GetEnvironmentVariableW (whether UNICODE or not) declared in <winbase.h> which is included in <windows.h>

The reason you get thi is because you include windows.h directly or indirectly.
To get rid of this compile error, you can just
   #undef GetEnvironmentVariable
before you use it.
0
 

Author Comment

by:judico
ID: 11784793
So #include "windows.h" (coming from the part of the code that was translated from unmanaged) messes up, after the merger, the part of the code that was managed to begin with. Now, I included, as you suggested, #undef GetEnvironmentVariable and it took care of  some errors but other errors still remain, such as:

error C2143: syntax error : missing ';' before '*'
temperature.h(45): error C2501: 'Q307398::temperature::MultiMeter' : missing storage-class or type specifiers
temperature.h(45): error C2501: 'Q307398::temperature::mmeter' : missing storage-class or type specifiers

How can I get rid of those errors too? Isn't there some clean way to get rid of the unmanaged code altogether?
0
 
LVL 16

Expert Comment

by:nonubik
ID: 11784864
The new error you posted looks like managed code.
The line 45 and 44 from temperature.h are needed in order to see what's on.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:judico
ID: 11785177
These are lines 44 and 45 are:

private: int evtCounter;
             MultiMeter *mmeter;

They work fine in the pre-merged code. Why don't they work here?
0
 
LVL 16

Expert Comment

by:nonubik
ID: 11785222
maybe you need to use some namespace or something, like:
using namespace somenamespace
0
 
LVL 16

Accepted Solution

by:
nonubik earned 125 total points
ID: 11785236
Seems that the compiler does not know about "MultiMeter" data type. Maybe you need to include some header file.
0
 

Author Comment

by:judico
ID: 11785396
Thanks a lot. The was exactly it. All the best.

judico
0
 

Author Comment

by:judico
ID: 11786215
Thanks a lot. This was exactly it. All the best.

judico
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
__FILE__ 6 180
Funky fonts displayed 7 88
c++ vs2003 loging the program jumps from function to function 4 67
Issues with Word font 4 88
The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question