Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Nios Errors: "First Defined Here" and "Multiple Definitions" for a single line

Hi Guys,

Long stopry short i'm pulling my hair out about a wierd errors and done all sorts of trials to find out what it is.

what i'm doing

I have two functions, 1 i made myself (get_de2_115_mac_addr) and a second i have copied from another project (FindLastFlashSectorOffset).

I have them working if i leave them in a single file inich_init.c.

What i want to do is move them to a seperate file sss_de2_115.c.

errors

shown in the attached image.

By moving these functions into a seperate .c file i get the two errors for each function .

"first defined here : sss_de2_115.c line 34" and

"multiple definition of 'get_de2_115_mac_addr' : sss_de2_115.c line 34"

The error pair for each function refer to the same f'n line! This is the only place they are mentioned or defined. I have tried doing it with or without a function protoype at the start of the file SSS_DE2_115.c. Still get the error.

#includes

Inich_init# includes SSS_De2_115, but the latter doesn't# include the former. SSS_DE2_115 does include some of the same headers as iniche_init but these are to prevent file type compile errors etc. To my knowledge these are system headers and shouldn't create a circular reference (i hope).

any help would be much appreciated. Code is attached as text files.

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Why do you# include another .c file in iniche_init.c? It shouldn't be included but simply added to your project.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks Daixiwen, I needed to include because the functions in SSS_DE2_115.c are being called from inich_innit.

    I have solved this issue by making a header file and putting the function definitions, global variables and# includes into it. Both the .c files now include this header and the header includes neither; this has worked.

    Thank you again for the reply Daixiwen
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Yes that's usually how you use header files and# include's in a C project ;)