cancel
Showing results for 
Search instead for 
Did you mean: 

Why am I receiving an compile error of "mutilple definition " for a variable when there is no extern declaration for either variable? They share the same name and are in different files.

GreenGuy
Lead

STM32H743i-EVAL, using 2.1.0 PACK, and H7_V1.11.0 firmware.

The error occurred after adding NetXDuo > Addons Web Server. I found to satisfy the compile errors that I also had to check (include) Addons DHCP Client and go back to RTOS ThreadX and check PerformanceInfo since there is a routine deep in the app_netxduo.c that needs to use performance information.

After this I am left with one error, a multiple definition for CHAR *pointer used in app_threadx.c to keep track of byte_pool allocations when creating threads for threadx and CHAR *pointer used in app_netxduo.c to keep track of byte_pool allocations there when creating the netx threads. Neither of the CHAR *pointers are declared as external nor is there any declarations made in the h files with respect to these variables that might cause a multiple reference.

I guess I could go in and give them a unique name, but I thought each declaration should be local to the file it is declared and used in.

1 ACCEPTED SOLUTION

Accepted Solutions
GreenGuy
Lead

I ended up moving the CHAR *pointer declaration into the respective thread_Init functions MX_NetXDuo_Init, and App_ThreadX_Init since that is the only place it is being used. All works OK.

View solution in original post

3 REPLIES 3
GreenGuy
Lead

I ended up moving the CHAR *pointer declaration into the respective thread_Init functions MX_NetXDuo_Init, and App_ThreadX_Init since that is the only place it is being used. All works OK.

GreenGuy
Lead

BTW I seem to recall that the CHAR *pointer statements started out at the PV define section of the app files making them global but other examples have them in the init functions.

KnarfB
Principal III

If the intention was that both definitions mean the same variable, all but one definition should use the storage-class specifier extern.

If the intention was that both definitions mean different variables, all definitions should use the storage-class specifier static.

If neither storage-class specifier is provided, you might have tentative definitions and the behaviour is undefined (compiler dependent). So that might have worked at one time on one system, but not alwasy on all systems.

hth

KnarfB