Solved

Contamination from unmanaged code in managed VC++.NET

Posted on 2004-08-12
8
874 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Outlook Font 8 110
Web browser fonts have gone wild. 8 129
a reliable reference for c+11? 3 94
Loading Self-Hosted Fonts 12 43
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

734 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