473,396 Members | 1,987 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,396 software developers and data experts.

__declspec(dllimport)

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

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

int main(void){
MyClass<&myvariable>::myfunction();
return 0;
}
/* end of code */

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

Feb 11 '06 #1
3 7626
<hs******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
:I have a query. Please help me out as soon as possible.
: Consider the below code snippet:
:
: /* code begins */
: __declspec(dllimport) int myvariable;
: template<const int *p>
: class MyClass{
: public:
: static void myfunction(){
: }
: };
:
: int main(void){
: MyClass<&myvariable>::myfunction();
: 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é(clipart) 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.vecerina.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.vecerina.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é(clipart) -- lovely!

--
Ben.

Feb 11 '06 #4

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

Similar topics

0
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...
3
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...
1
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...
5
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...
2
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...
1
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
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:...
1
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...
6
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....
9
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...
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
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,...
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...
0
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...
0
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,...

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.