473,583 Members | 3,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

__declspec(dlli mport)

I have a query. Please help me out as soon as possible.
Consider the below code snippet:

/* code begins */
__declspec(dlli mport) int myvariable;
template<const int *p>
class MyClass{
public:
static void myfunction(){
}
};

int main(void){
MyClass<&myvari able>::myfuncti on();
return 0;
}
/* end of code */

Will the adderss of myvariable be treated as a constant ???

Feb 11 '06 #1
3 7652
<hs******@gmail .com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
:I have a query. Please help me out as soon as possible.
: Consider the below code snippet:
:
: /* code begins */
: __declspec(dlli mport) int myvariable;
: template<const int *p>
: class MyClass{
: public:
: static void myfunction(){
: }
: };
:
: int main(void){
: MyClass<&myvari able>::myfuncti on();
: return 0;
: }
: /* end of code */
:
: Will the adderss of myvariable be treated as a constant ???

What do you mean?
As a compile-time constant: definitely not.
Constant during program execution: definitely yes.
You probably want to know if, across compilation
units [or is it across DLLs?] whether all instances
of My<&my> will be the same?
The answer is, we can't say based on the C++ standard,
because __déclassé(clip art) is a platform-specific
extension. So you would have to ask on a dedicated
forum -- or probably easier, test it for yourself.

For example, within my(), add a test declaration
such as:
static int dummy = ((std::cout<<
"!!!a My::my::dummy instance is created!!!!"
),1);
You will see in the console input if separate instances
of the template function are being called.
Cheers,
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com
Feb 11 '06 #2
"Ivan Vecerina" <IN************ *****@ivan.vece rina.com> wrote in message
news:ds******** **@news.hispeed .ch...
: For example, within my(), add a test declaration
: such as:
: static int dummy = ((std::cout<<
: "!!!a My::my::dummy instance is created!!!!"
: ),1);
: You will see in the console input if separate instances
: of the template function are being called.

Sorry, I have blindly clicked "replace" instead if
"ignore" as the spell-checker was reviewing my post.
Therefore the odd substitutions -- which I am sure
will be easily reverted (My->MyClass, my->myfunction).
Feb 11 '06 #3
On Sat, 11 Feb 2006 03:12:00 +0100, Ivan Vecerina wrote:
"Ivan Vecerina" <IN************ *****@ivan.vece rina.com> wrote in message
news:ds******** **@news.hispeed .ch...
: For example, within my(), add a test declaration : such as:
: static int dummy = ((std::cout<<
: "!!!a My::my::dummy instance is created!!!!" : ),1);
: You will see in the console input if separate instances : of the
template function are being called.

Sorry, I have blindly clicked "replace" instead if "ignore" as the
spell-checker was reviewing my post. Therefore the odd substitutions --
which I am sure will be easily reverted (My->MyClass, my->myfunction).


I particularly liked __déclassé(clip art) -- lovely!

--
Ben.

Feb 11 '06 #4

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

Similar topics

0
1698
by: .NET developer | last post by:
Hi, I am trying to compile my VC6 application on VC++7. It give following linker error. __declspec(dllimport) public: class ATL::CStringT<unsigned short,class StrTraitMFC_DLL<unsigned short,class ATL::ChTraitsCRT<unsigned short> > > __thiscall CHPCmdExecFrame::GetStringParam(int,int *)"...
3
2597
by: Gawel | last post by:
Hajo, I have two dlls, both of them are compiled with /clr switch. In first dll project I have managed and unmanaged classes. One of the unmanaged I would like to use outside therefore I marked it as follows: class __declspec(dllexport) Terrain { public: void foo(){} };
1
1292
by: Geoffrey | last post by:
We write lots of cross platform code at my company. To facilitate this, class declarations are handled like this (simplification): #if defined(_WIN32) #if defined(BUILDLIB) #define CLASSDECLARE( c ) class __declspec(dllexport) c #else #define CLASSDECLARE( c ) class c //note the absence of dllimport #endif #endif
5
2043
by: Felix I. Wyss | last post by:
Good Afternoon, I recently noticed that some very simple methods of a template declared and used in a DLL library get inlined when used by the DLL itself, but not by other DLLs and EXEs. After some investigating, I narrowed this down to a very odd behavior (bug?) of the VC++.NET 2003 compiler: If a class that is declared as...
2
2429
by: .NET developer | last post by:
Hi , While upgrading my application from vc6 to vc7 I got followin linking errors : __declspec(dllimport) public: class ATL::CStringT<unsigned short,class StrTraitMFC_DLL<unsigned short,class ATL::ChTraitsCRT<unsigned short> > > __thiscall CHPCmdExecFrame::GetStringParam(int,int *)"...
1
546
by: hsharsha | last post by:
Consider the below code: extern __declspec(dllimport) int myvariable; template<const int *p> class MyClass{ public: static void myfunction(){ } };
1
7280
by: sharmadeep1980 | last post by:
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error: Creating library Release/fnimqcmd.lib and object Release/fnimqcmd.exp CoIMQCmd.obj : error LNK2001: unresolved external symbol
1
4260
by: kardon33 | last post by:
Let me explain my problem, Im currently trying to use a Perl module that was built for a Windows OS that uses a .dll and .lib file. I have obtained the c header files that the modules were built with. I am trying to use SWIG to write my Perl mod with those files but I getting a bunch of errors with the "extern "C" __declspec(dllimport)"...
6
2641
by: vivekanandaprasanth | last post by:
hi, I have exported a class which i have written in win32 static lib app. Now i have written a wrapper class for the same. But when i am trying to compile it is giving me some linker errors. Here is the class information //This is MyClass.h file #define DllImport __declspec( dllimport )
9
8201
by: jjones7947 | last post by:
Am doing a JNI wrap on a C++ API, am using VC7 and Eclipse. In preparation, I created a C++ executable which mimicked the flow of the JNI, i.e. a driver file which called methods in file with methods which call the API functions I want to use. That compiled and ran well. The C++ code is as follows: My header file void createSummarizer(char*...
0
7821
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...
0
8172
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8317
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...
1
7928
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...
0
8188
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...
0
5369
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...
0
3813
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...
0
3839
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1422
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.