Solved

Contamination from unmanaged code in managed VC++.NET

Posted on 2004-08-12
8
866 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
 

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now