473,387 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 3848
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Klaus Schneider | last post by:
Hi all! I'm having trouble with a template function with variable arguments when I parse an enum type as variable argument. Example: template <class T> bool test(int num, ...) { va_list ap;...
1
by: Bill Cohagan | last post by:
I've got an abstract class (say foo) and I'd like to define an Enum (say bar) within that class so that I can then refer to foo.bar.<one of the enum labels> from within other parts of the program....
1
by: Geoff Hilyard | last post by:
Using VS.net 2003 / Managed C++ I have created a base object (public __gc CBaseObject) that everything in my project inherits from (Similar to how everything really inherits system::Object). I...
2
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking afterwards with ILDASM at what is visible in those assemblies from a...
10
by: kar1107 | last post by:
Hi all, Can the compiler chose the type of an enum to be signed or unsigned int? I thought it must be int; looks like it changes based on the assigned values. Below if I don't initialize...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
5
by: Francois Grieu | last post by:
Does this reliably cause a compile-time error when int is not 4 bytes ? enum { int_size_checked = 1/(sizeof(int)==4) }; Any better way to check the value of an expression involving sizeof...
15
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
How can I pass a C++ HWND to and from C# and Managed C++?
8
by: benn | last post by:
Here's the setup... Defines.h file contains: enum DAY { monday, tueday }; DayFunctions.h contains prototype: void printIsMonday ( enum DAY currentDay); DayFunctions.c contains:
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.