Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID


We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Extern Function in C/C++

tatyakadamtatyakadam Posts: 2Member
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 :


  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [color=Blue]Try to remove "extern" from function prototype. It is needed only for variables.[/color]
  • LundinLundin Posts: 3,711Member
    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.