Extern Function in C/C++

int f1(int x, int y)
printf("%d %d", x, y);
return x+y;

extern int f1(int x,int y);
void main()
printf(" %d
", f1(5,6));

I was trying complie Simple1.c file then Simple2.c on Turbo C/C++ Compiler (Windows Xp). It showing following error :
Compiling Sample2.c :
Linking Sample2.exe:
Linker Error : Undefined Symbol _f1 in module Sample2.c

Can any body help me regards this.
my mail id is : tatyakadam@tataelxsi.co.in


  • [color=Blue]Try to remove "extern" from function prototype. It is needed only for variables.[/color]
  • Actually, plain function prototypes like

    void func (void);

    are declared extern implicitly. So the above is just the same as

    extern void func (void);

    though the latter is more "stylish".


    The problem in this case is the lack of header files. Make a h-file for each c-file and put the prototypes in the h-files.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!