Accessing a function from another .C file

I am trying to access a function from defined in one *.C function and implement it in another *.C file. The code goes:

#include "file1.h"
#include "file2.h"

int someFunction() {
 int function0 ();
 function0 = functionFromFile2 ();
 //other tasks here
#ifndef FILE1
#define FILE1

int someFunction();
#include "file2.h"

int functionFromFile2() {
#ifndef FILE2
#define FILE2

int functionFromFile2();


I load the function

> .L file1.C
> someFunction()

gives the complain

functionFromFile2() declared but not defined .....

Aren’t the necessary ‘includes’ in place?

It works OK if I load the *.C files as

> .L file1.C
> .L file2.C
> someFunction()


try to think about the message you were given:

So yes, the correct includes were in place to pull in the declaration of that function. The definition is in the *.C file which isn’t included. Loading it makes the definition visible.

Would it not make it tedious to load Godzillion *.C files for a more complicated program? :unamused:

You can always create a single *.C file which includes every other *.C file you care about. Alternatively creating a shared library is a proper solution and expecting CINT to magically know declarations of your functions is asking a little too much from it.

Ok, thank you. I think thats a better way to respond rather than responding rudely.

Oh sorry, I didn’t want to be offensive but rather reassure you in making better use of the already surprisingly useful diagnostic message from CINT.