Hi,
I have the following code - FIRST.CPP, CALL.C and stdafx.h
FIRST.CPP:
Code:
#include "stdafx.h"
extern "C" void callmethod();
int _tmain(int argc, _TCHAR* argv[])
{
callmethod();
return 0;
}
void justcall(){
#ifdef __cplusplus
printf("This is C++");
#else
printf("This is C code");
#endif;
}
CALL.C
Code:
void callmethod(){
justcall();
}
stdafx.h:
Code:
#include <stdio.h>
#include <tchar.h>
extern "C" void justcall();
The output when I run FIRST.CPP is "This is C++".
From FIRST.CPP, I call callmethod() which is defined in a .c file and from this callmethod() I call justcall() which is in a .cpp file.
My question is justcall() is called from a C program then why is the code inside #ifdef _cplusplus getting executed?
Thanks,
Chandana.