473,722 Members | 2,459 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_MCP P1;

// The compiler gives a warning C4677 for this:
// 'm_eEnumType_MC PP2': signature of non-private
// function contains assembly private type
// 'MCPP_ClassLib1 ::eEnumType_MCP P'
//
// static enum eEnumType_MCPP m_eEnumType_MCP P2;
};
}

For reference:
http://msdn.microsoft.com/library/en...clarations.asp
Nov 17 '05 #1
5 3871
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_MCP P2;

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

--------------------
| From: Alan Cobb <al***********@ spam.off.alanco bb.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.publi c.dotnet.langua ges.vc
| NNTP-Posting-Host: 177.119-30-64.ftth.swbr.su rewest.net 64.30.119.177
| Lines: 1
| Path:
cpmsftngxa10.ph x.gbl!TK2MSFTFE ED01.phx.gbl!TK 2MSFTNGP08.phx. gbl!TK2MSFTNGP1 1
.phx.gbl
| Xref: cpmsftngxa10.ph x.gbl microsoft.publi c.dotnet.langua ges.vc:36168
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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_MCP P1;
|
| // The compiler gives a warning C4677 for this:
| // 'm_eEnumType_MC PP2': signature of non-private
| // function contains assembly private type
| // 'MCPP_ClassLib1 ::eEnumType_MCP P'
| //
| // static enum eEnumType_MCPP m_eEnumType_MCP P2;
| };
| }
|
| For reference:
|
http://msdn.microsoft.com/library/en...c.2b2b_.enumer
ation_declarati ons.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_MCP P2;


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_MCP P2;


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
3452
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; int ind;
1
4696
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. The enum is *public* in other words. What I find is that while the compiler allows the enum declaration within the abstract class, it turns out that the enum type isn't visible from outside the class. It is visible from within descendant...
1
1409
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 have a Heap class that I have made into a DLL. In this dll, I include CBaseObject (I have to dynamic cast to it for access to some of its functions). This is made into a dll for use in several other projects. However, when I include (I guess...
2
2054
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 managed point-of-view I've noticed that: 1) for each managed and unmanaged C function (not C++ classes) I get a public managed static method (defined on a 'Global Functions' class) in the generated assembly with an export name of the form
10
23602
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 FOO_STORE to be, say -10, I get a warning about unsigned comparison and I'm seeing an infinite loop. If I do initialize FOO_STORE = -10, I don't see any warnings. No infinite loop.
34
11194
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 snippet that I wrote today that gives me an instant implementation of the pattern. I could easily just always use such an implementation instead of a standard enum, so I wanted to know what you experts all thought. Is there a case for standard enums?
5
2896
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 before runtime ? I also have: { void check_foo_size(void);
15
30106
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
How can I pass a C++ HWND to and from C# and Managed C++?
8
8555
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
8867
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9239
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9158
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8059
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4764
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2606
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2148
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.