So much to compile, so little time...

Hello. I haven't quite mastered dealing with compiling lots of functions that all call each other in sophisticated fashions.

Let's say that I have a few functions:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// function_1

#include <iostream>

using namespace std;

int function_2(/*junk*/);
int function_3(/*much_junk*/);
.
.
.
int function_n(/*more_junk*/);

main()
{
    // This uses the junk
}


[code]
// function_2

#include <iostream>

using namespace std;

int function_23();
int function_42();

function_2()
{
// Much more junk //
}
[\code]

What would be the best way of getting this to compile?
What would be the best way of getting this to compile?

Adding the return types in front of main() and function_2() would be a good step in the right direction.
Last edited on
lol, of course, go ahead and assume they're 'int'.
Well, could I simply use a compile line that looks like this?

g++ -o myfunction function_1.cpp function_2.cpp ... function_n.cpp

If this works, it's still a little cumbersome. Is there a better way to handle this?
This makes it a little clearer.

You can have as many functions as you want in a single file. That would prevent you from typing all of those annoying characters. However it is often a good idea to keep it split. If you have seperate .cpp files that are all sharing functions, try putting the pre-declared functions into a header (.h) file. Then call that .h file in each of your source files (.cpp).

This will make things a little smoother for you.
Topic archived. No new replies allowed.