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
Solved

Contamination from unmanaged code in managed VC++.NET

Posted on 2004-08-12
8
872 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…

792 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