extra feature on function syntax, what is it for?

M

michael.goossens

I'm a beginning c++ user, pretty handy at java already but I want to
transfer to c++. Particullary because c++ is way better in processing
graphical processes and mathematical calculations fast. So I was
looking at some code of a graphic tool and stumbled on this:

COREDLL void pbrtCleanup() {
StatsCleanup();
// API Cleanup
if (currentApiState == STATE_UNINITIALIZED)
Error("pbrtCleanup() called without pbrtInit().");
else if (currentApiState == STATE_WORLD_BLOCK)
Error("pbrtCleanup() called while inside world block.");
currentApiState = STATE_UNINITIALIZED;
delete renderOptions;
renderOptions = NULL;
}

Which is a function and I always thought it was <output type>
fct_name(<input types) by syntax. But now there is an extra feature in
front of the output type, the COREDLL thing in this case. Can someone
explain this to me?

Also on top of the page there is something defined like:
COREDLL ParamSet NullParams;

I'm not sure if I saw it before a class definition too or not but if
so I would like to know about it too :).

Thanks alot already

ps: you can see the code where I got this from at http://prideout.net/pbrt/api.cpp
 
J

Jack Klein

I'm a beginning c++ user, pretty handy at java already but I want to
transfer to c++. Particullary because c++ is way better in processing
graphical processes and mathematical calculations fast. So I was
looking at some code of a graphic tool and stumbled on this:

COREDLL void pbrtCleanup() {
StatsCleanup();
// API Cleanup
if (currentApiState == STATE_UNINITIALIZED)
Error("pbrtCleanup() called without pbrtInit().");
else if (currentApiState == STATE_WORLD_BLOCK)
Error("pbrtCleanup() called while inside world block.");
currentApiState = STATE_UNINITIALIZED;
delete renderOptions;
renderOptions = NULL;
}

Which is a function and I always thought it was <output type>
fct_name(<input types) by syntax. But now there is an extra feature in
front of the output type, the COREDLL thing in this case. Can someone
explain this to me?

Well, not in detail, because it is not something defined by C++.

"COREDLL" is either one of two things:

1. Some sort of non-standard, compiler/platform specific macro that
tells the compiler to do something out of the ordinary, such as use a
particular calling or parameter passing interface.

2. Even more likely, a macro that expands to something equivalent to
number 1.

A quick Google for "COREDLL" turns up links that seem to indicate that
is an extension used particularly for Windows CE, and not.

For more information:

http://www.google.com/search?hl=en&q=COREDLL&btnG=Google+Search
Also on top of the page there is something defined like:
COREDLL ParamSet NullParams;

I'm not sure if I saw it before a class definition too or not but if
so I would like to know about it too :).

Thanks alot already

If you don't program for Windows CE, or even better, never heard of
Windows CE, you cannot use this code, at least as it is written.

If you do program for Windows CE, and want more information, try
Microsoft's MSDN web site or Windows CE specific newsgroups. It is a
Windows thing, not a C++ one.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
 
T

Tomás Ó hÉilidhe

(e-mail address removed):
COREDLL void pbrtCleanup()


You'll probably find that COREDLL is a #define for something like
"__stdcall". So what you have would be:

__stdcall void pbrtCleanup()

The C++ Standard doesn't have any mention of anything like "__stdcall", but
on your own particular platform it might mean something like "this function
is to be provided as an exported function in the DLL file".
 
M

michael.goossens

yeah you are right, I got this information too :). thanks!

COREDLL is a macro defined in pbrt.h. The reason is that on windows
systems you need __declspec() commands to import/export class
definitions to/from dll's (I forget which). For unix systems the
COREDLL token will be removed by the preprocessor.

#ifdef WIN32

#ifdef CORE_SOURCE
#define COREDLL __declspec(dllexport)
#else
#define COREDLL __declspec(dllimport)
#endif
#define DLLEXPORT __declspec(dllexport)

#else

#define COREDLL
#define DLLEXPORT

#endif
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,096
Latest member
ThurmanCre

Latest Threads

Top