This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

extern "C" - bug or feature


First of all, I have wondered that this simple question I want to ask you is
not on the page with bugs already.
The situation is very simple (gcc 2.95.2, cygwin-686).

I have approximately the following structure of program :

main.cpp :

extern "C" {
#include "struct.h"
}
#include <stdio.h>
void main() { printf ("sizeof(struct s2) = %d\n", sizeof(struct s2); }


struct.h :

struct s1 { long a; };
struct s2 { struct s1; long b; };


That's all!
When I've compiled the main.cpp I get the result : 4. But when rename it (to
main.c) , then delete 2 lines (extern "C"), then compile, I get result : 8.
I REALLY UNDERSTAND that in C++ I get the right result, if I've NOT
SPECIFIED extern "C". But I specified. Is the result I got right????

Hoping for an answer.

Anton



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]