1

Possible Duplicate:
What is __gxx_personality_v0 for?

I've seen this question circulating around here in the context of compiling C++ code. However I am to compile a pure C code and keep on getting this error. I am forbidden to use "-lstdc++" as a workaround to this gcc problem. How to change my code to get it working and why is this error popping out?

My simplified code:

//this is main.cpp
#include <stdio.h>
int main()
{
    char ch[3];
    ch[0] = getc(stdin);
    ch[1] = getc(stdin);
    ch[2] = '\0';
    printf("%s\n", ch);
    return 0;
}

My compile command is:

gcc main.cpp
Community
  • 1
  • 1
infoholic_anonymous
  • 969
  • 3
  • 12
  • 34

2 Answers2

11

Use either g++ - since your file is suffixed .cpp or rename the file to .c and keep the command line as is. Tested on Debian 6.0.5 with gcc 4.4.5.

0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
0

man gcc says:

C++ source files conventionally use one of the suffixes .C, .cc, .cpp, .CPP, .c++, .cp, or .cxx; C++ header files often use .hh, .hpp, .H, or (for shared template code) .tcc; and preprocessed C++ files use the suffix .ii. GCC recognizes files with these names and compiles them as C++ programs even if you call the compiler the same way as for compiling C programs (usually with the name gcc).

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
maverik
  • 5,508
  • 3
  • 35
  • 55