473,606 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Static member variables

I have an MFC Extension DLL that I have flicked the /clr switch on and made a
few other tweaks so it compiles and runs in a managed MFC applicaiton.

The DLL contains a number of classes which contain static member variables
and static methods. Are these permitted in a managed DLL?

Thanks

Colin
Nov 25 '05 #1
3 1245
JAL
Colin... All I can say is that MSIL understands static (class) methods and
variables so that you can certainly declare and use static member methods and
variables in a purely managed language as C#. C# does not support static
local variables. I don't (yet) have any C++/cli code for this so this is C#:

class TestStatic
{
// static stuff
private static int uniqueID= 0;
private static int GetUniqueID()
{
lock(typeof(Tes tStatic))
{
return uniqueID++; // returns zero at start
}
}

// member stuff
private int identity;
public TestStatic()
{
this.identity= TestStatic.GetU niqueID();
}
public int Identity
{
get
{
return identity;
}
}
}

"Colin Desmond" wrote:
I have an MFC Extension DLL that I have flicked the /clr switch on and made a
few other tweaks so it compiles and runs in a managed MFC applicaiton.

The DLL contains a number of classes which contain static member variables
and static methods. Are these permitted in a managed DLL?

Thanks

Colin

Nov 26 '05 #2
I have done quite a lot with /clr so far, and I have not seen problems with
static member variables of native types so far.

Marcus Heege

"Colin Desmond" <Co**********@d iscussions.micr osoft.com> wrote in message
news:35******** *************** ***********@mic rosoft.com...
I have an MFC Extension DLL that I have flicked the /clr switch on and made
a
few other tweaks so it compiles and runs in a managed MFC applicaiton.

The DLL contains a number of classes which contain static member variables
and static methods. Are these permitted in a managed DLL?

Thanks

Colin

Nov 28 '05 #3
Marcus,

Thanks for this support, turns out my problems lay elsewhere.

Thanks again

Colin

"Marcus Heege" wrote:
I have done quite a lot with /clr so far, and I have not seen problems with
static member variables of native types so far.

Marcus Heege

"Colin Desmond" <Co**********@d iscussions.micr osoft.com> wrote in message
news:35******** *************** ***********@mic rosoft.com...
I have an MFC Extension DLL that I have flicked the /clr switch on and made
a
few other tweaks so it compiles and runs in a managed MFC applicaiton.

The DLL contains a number of classes which contain static member variables
and static methods. Are these permitted in a managed DLL?

Thanks

Colin


Nov 29 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
4379
by: Alexander Mahr | last post by:
Dear Newsgroup, I'm somehow confused with the usage of the static keyword. I can see two function of the keyword static in conjunction with a data member of a class. 1. The data member reffers in all objects of this class to the same data Or in other word by using the static keyword all objects of one class can share data. (This is what I want)
25
5147
by: Sahil Malik [MVP] | last post by:
So here's a rather simple question. Say in an ASP.NET application, I wish to share common constants as static variables in global.asax (I know there's web.config bla bla .. but lets just say I wanna use global.asax) --- Would you declare your static var as --- public static int x ;
25
1957
by: Sahil Malik [MVP] | last post by:
So here's a rather simple question. Say in an ASP.NET application, I wish to share common constants as static variables in global.asax (I know there's web.config bla bla .. but lets just say I wanna use global.asax) --- Would you declare your static var as --- public static int x ;
1
3154
by: mangalalei | last post by:
A static data member can be of the same class type as that of which it is a member. A nonstatic data member is restricted to being declared as a pointer or a reference to an object of its class. And I haved used the sizeof operator to test a class which has a static data member, the class size is all the nonstatic data member except the static data member. In compiler's view, is the static data member constructed after the whole class...
17
8365
by: Juha Nieminen | last post by:
As we know, the keyword "inline" is a bit misleading because its meaning has changed in practice. In most modern compilers it has completely lost its meaning of "a hint for the compiler to inline the function if possible" (because if the compiler has the function definition available at an instantiation point, it will estimate whether to inline it or not, and do so if it estimates it would be beneficial, completely regardless of whether...
0
8009
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
7939
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8428
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
8078
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
8299
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
6753
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...
1
5962
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5456
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1548
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.