Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ and mouthwash

Name: Anonymous 2010-04-27 11:35

Having a problem figuring out an error when I compile an object.

I have a .c file that I'm not supposed to modify, but need to use a function from inside a .h+.cpp object file.  The error has to deal with scope as the compiler (g++) complains.

I understand that normally I should use objectname::function, but since the function I need to use is contained outside the object, I'm not sure what the scope is.

Also, I've been trying to compile it like this:
g++ hurr.c derp.h derp.cpp -o derp.o

Perhaps this isn't correct but I'm not sure of another way while retaining the .c file and not simply copying its contents.

Name: Anonymous 2010-04-27 16:12

>>18
derp.cpp does not have a main function.  It's an object file, to be compiled to .o

hurr.c has no header, no prototypes, and no main; it has typical std c includes and then goes straight into declaring what the function is.  I'm not supposed to change anything in it, but a prototype for it is: void hurrfunction(); (it just does stuff on its own)

Sorry for frustrating you guys :(  I'm more trying to get an answer to something extremely similar than just have you guys write the whole thing, you know?

If I just plain declare it within derp.h or derp.cpp, I get this error:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List