CRT code question

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

lonnifer
Posts:3
Joined:Mon Apr 28, 2008 9:06 pm
CRT code question

Post by lonnifer » Sat May 03, 2008 2:54 pm

Hi, I have been reading through the CRT design tutorial, and I noticed that a lot of the headers have extern "C" constructs such as:

Code: Select all

#ifdef __cplusplus
extern "C"
{
#endif
...
...
...
#ifdef __cplusplus
}
#endif 
as far as I understand, the purpose of extern "C" is to avoid name mangling by C++ compilers, so that the functions prototyped between the brackets may be called by other C/asm modules.

However, in a lot of the header files, the extern "c" is used on a typedef or a #define directive, such as:

Code: Select all

#ifdef __cplusplus
extern "C"
{
#endif

typedef unsigned size_t;

#ifdef __cplusplus
}
#endif
What is the purpose of extern "C" in cases like this?

Post Reply