469,579 Members | 1,096 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

Public managed enum types in MCPP - Compiler warning

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...clarations.asp
Nov 17 '05 #1
5 3636
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).

--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #2
> 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.

--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #3
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 <al***********@spam.off.alancobb.spam.off.com>
| Subject: Public managed enum types in MCPP - Compiler warning
| Date: Tue, 27 Apr 2004 16:08:04 -0700
| Message-ID: <9i********************************@4ax.com>
| 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!TK2MSFT NGP08.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...c.2b2b_.enumer
ation_declarations.asp
|

Nov 17 '05 #4
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 ;)).

--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #5
On Wed, 28 Apr 2004 00:39:01 GMT, si*****@online.microsoft.com (Silviu
Guea [MSFT]) wrote:
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
Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Klaus Schneider | last post: by
1 post views Thread by Bill Cohagan | last post: by
10 posts views Thread by kar1107 | last post: by
34 posts views Thread by Steven Nagy | last post: by
5 posts views Thread by Francois Grieu | last post: by
15 posts views Thread by =?Utf-8?B?Sm9hY2hpbQ==?= | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.