Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help compiling C in C++

Status
Not open for further replies.

bobbybobbertson

Programmer
Nov 9, 2001
119
US
I am trying to compile a program written in C in a C++ compiler. It compiles fine, but when I run the program there is no output?

I am hoping this is a common problem when trying to convert, and someone might have a quick fix?

Supposedly you are supposed to be able to compile C programs in a C++ compiler.

Anyone know why this might be happening?
 
Try to run it through gdb, and see if it prints to the screen in gdb. It could be that your standard output was redirected for some reason or another. Just some ideas...
 
hi,
we cannot call porting this operation:
C language is a subset of C++;

write a simple program
main()
{
printf("hallo\n")
}

and compile it (gcc, g++ or ccc ...)

what appens ?

If it prints, make corrections in your and this progs,
until they are similar, and one of them change to go or not.

In that point there is the cause.

bye
 
Hi
To link C code with C++ code use the follow MACRO :

all the includes

#ifdef __cplusplus
extern "C" {
#endif

Your code
...

#ifdef __cplusplus
}
#endif

The C++ compiler add sufixx to the function and the C Compiler doesn't add any suffix.
This Macro will help you.




 
Hi,
What is the version of the C++ compiler ?

Regards,

Tushnim
 
Thanks for all the suggestions, I will try them out. I am not sure of the compiler version, as this is not actually my problem. I just wanted to see if this was a normal problem, and what peoples first reactions were.

If my friend solves the problem, I will post the results.

thanks kindly for your responses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top