Public managed enum types in MCPP - Compiler warning

A

Alan Cobb

Hi,

In the managed C++ class below I get compile warning C4677
from VS2003. "signature of non-private function contains
assembly private type", even though the managed enum is
public. I have to drop the "enum" keyword from my member
variable declaration to keep the compiler happy.

Shouldn't I technically be able to use the "enum" keyword
without a warning?

Thanks,
Alan Cobb

namespace MCPP_ClassLib1
{
public __value enum eEnumType_MCPP { eMem1, eMem2 };

public __gc class Class_MCPP // Managed class
{
public:
// The compiler likes this:
static eEnumType_MCPP m_eEnumType_MCPP1;

// The compiler gives a warning C4677 for this:
// 'm_eEnumType_MCPP2': signature of non-private
// function contains assembly private type
// 'MCPP_ClassLib1::eEnumType_MCPP'
//
// static enum eEnumType_MCPP m_eEnumType_MCPP2;
};
}

For reference:
http://msdn.microsoft.com/library/en-us/vclang/html/_pluslang_c.2b2b_.enumeration_declarations.asp
 
T

Tomas Restrepo \(MVP\)

Hi Alan,
In the managed C++ class below I get compile warning C4677
from VS2003. "signature of non-private function contains
assembly private type", even though the managed enum is
public. I have to drop the "enum" keyword from my member
variable declaration to keep the compiler happy.

Shouldn't I technically be able to use the "enum" keyword
without a warning?

I think so. FWIW, the compiler seems to generate the correct code anyway.
Certainly a bug worth reporting, although doubtful to be corrected since
there's an easy workaround, and the language syntax is changing.... (and it
*seems* to have been fixed in the new syntax, but I really can't tell for
sure yet).
 
T

Tomas Restrepo \(MVP\)

I think so. FWIW, the compiler seems to generate the correct code anyway.
Certainly a bug worth reporting, although doubtful to be corrected since
there's an easy workaround, and the language syntax is changing.... (and it
*seems* to have been fixed in the new syntax, but I really can't tell for
sure yet).

OK, it was fixed... up to a point. In the new syntax, it seems you need to
do it in *exactly* the same way. So if you defined the value enum as "enum
class" (the new syntax for __value enum), then the second time it should
also say "enum class ....", and not just enum.
 
S

Silviu Guea [MSFT]

There is actually an error in your code:
You're redeclaring the same enum as an unmanaged one.

Try something like this:
static __value enum eEnumType_MCPP m_eEnumType_MCPP2;

--
Silviu Guea, Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights.

--------------------
| From: Alan Cobb <[email protected]>
| Subject: Public managed enum types in MCPP - Compiler warning
| Date: Tue, 27 Apr 2004 16:08:04 -0700
| Message-ID: <[email protected]>
| X-Newsreader: Forte Agent 1.92/32.572
| MIME-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| Newsgroups: microsoft.public.dotnet.languages.vc
| NNTP-Posting-Host: 177.119-30-64.ftth.swbr.surewest.net 64.30.119.177
| Lines: 1
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.vc:36168
| X-Tomcat-NG: microsoft.public.dotnet.languages.vc
|
| Hi,
|
| In the managed C++ class below I get compile warning C4677
| from VS2003. "signature of non-private function contains
| assembly private type", even though the managed enum is
| public. I have to drop the "enum" keyword from my member
| variable declaration to keep the compiler happy.
|
| Shouldn't I technically be able to use the "enum" keyword
| without a warning?
|
| Thanks,
| Alan Cobb
|
| namespace MCPP_ClassLib1
| {
| public __value enum eEnumType_MCPP { eMem1, eMem2 };
|
| public __gc class Class_MCPP // Managed class
| {
| public:
| // The compiler likes this:
| static eEnumType_MCPP m_eEnumType_MCPP1;
|
| // The compiler gives a warning C4677 for this:
| // 'm_eEnumType_MCPP2': signature of non-private
| // function contains assembly private type
| // 'MCPP_ClassLib1::eEnumType_MCPP'
| //
| // static enum eEnumType_MCPP m_eEnumType_MCPP2;
| };
| }
|
| For reference:
|
http://msdn.microsoft.com/library/en-us/vclang/html/_pluslang_c.2b2b_.enumer
ation_declarations.asp
|
 
T

Tomas Restrepo \(MVP\)

Hi Silviu,
There is actually an error in your code:
You're redeclaring the same enum as an unmanaged one.

Try something like this:
static __value enum eEnumType_MCPP m_eEnumType_MCPP2;

Actually, that won't work either (I tried it ;)).
 
A

Alan Cobb

There is actually an error in your code:
You're redeclaring the same enum as an unmanaged one.

Try something like this:
static __value enum eEnumType_MCPP m_eEnumType_MCPP2;

Hi Silviu,

Like Tomas I also had tried "__value enum" and got the same warning
with VS2003. I probably should have left it that way in my original
demonstration post, because that seems like the way it probably
should work.

Alan Cobb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top