User forums > General (but related to Code::Blocks)
C Header Files Inclusion
Anark10n:
I doubt it's a mix of c and c++, see for yourself:
My header file: Largest.h
int maximum(int x, int y, int z);
My function definitions: LargestDef.c
#include "Largest.h"
int maximum(int x, int y, int z)
{
int maxNum = x;
if (maxNum < y)
{
maxNum = y;
}
if (maxNum < z)
{
maxNum = z;
}
return maxNum;
}
My main function
#include <stdio.h>
#include "Largest.h"
int main()
{
int num1;
int num2;
int num3;
printf("Enter three integers: ");
scanf("%d %d %d", &num1, &num2, &num3);
printf ("Largest: %d", maximum(num1, num2, num3));
return 0;
}
Not certain whether its appropriate to post code samples here, so apologies if it is not.
stahta01:
--- Quote from: Anark10n on April 28, 2010, 01:40:07 pm ---I doubt it's a mix of c and c++, see for yourself:
--- End quote ---
I suggest turning on full compiler logging.
Or, renaming main.cpp to main.c (if it was named wrong).
Tim S.
Anark10n:
File containing the main function is also a .c file, sorry about the omission. As for the solutions, no luck; being new to code blocks, i don't exactly know what it is I'm supposed to look for in the compiler logs. Not a surprise though that it compiles fine if i chuck all the code in the same file.
oBFusCATed:
--- Quote from: oBFusCATed on April 22, 2010, 02:38:25 pm ---Read this: http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
--- End quote ---
Anark10n:
Thanks for the help, played around with the compiler options (had to look in a lot of places to figure it out), got everything to link properly. Not the most elegant of solutions, but at least it works. Great IDE by the way, hooray for open source...
Navigation
[0] Message Index
[*] Previous page
Go to full version