File Inclusion: Multiple files with the same name and function

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

File Inclusion: Multiple files with the same name and function

252 Views
karmegancjk
Contributor III

Hi,

I have MATLAB-generated .c and .h files included in my S32DS IDE application project.

In this project, I have separate application and library files for each timing interval: 1 ms, 10 ms, 50 ms, and 100 ms.

Each of these timing-based libraries (e.g., 1 ms, 10 ms, etc.) contains files like rte.c/.h and rtd_init.c/.h. These files include a function with the same signature, for example:

void get(uint8_t a);

So, in:

  • 1 ms: rte.c/.h and rtd_init.c/.h → contains void get(uint8_t a);

  • 10 ms: rte.c/.h and rtd_init.c/.h → also contains void get(uint8_t a);

  • 50 ms: same structure and function

  • 100 ms: same structure and function

The problem is, while building the project, I get multiple definition errors, since the same function (get) with the same name exists in multiple libraries.

What I want is:

  • If I’m calling a 1 ms function, it should use only the 1 ms version of rte.c/.h and rtd_init.c/.h

  • If calling a 10 ms function, it should use only the 10 ms version of those files

But right now, I cannot include them conditionally like this.

Is there any configuration setting, build setup, or recommended method in S32DS to manage this kind of situation where multiple libraries contain same-named files and functions?

thanks and Regards,

Karmegan C.

Tags (2)
0 Kudos
Reply
1 Reply

225 Views
stanish
NXP Employee
NXP Employee

Hello Karmegan, 

I can imagine you create a separate build configuration per each timing interval.

stanish_0-1756126047525.png

The output executable  (.elf) would only consist from 1ms methods and 1ms lib. Similarly to other timing configurations

In order to avoid multiple definition errors you can exclude all others .c files and libraries from the build configuration. See below the Build Configuration Explorer you can use to select source to be used by the specific build configuration. Excluded sources are crossed and grayed in the project manager View.

 

stanish_2-1756126624776.pngstanish_1-1756126462121.png

If it does not meet your need please specify your goal more in the details.

Hope it helps.

Stan

 

0 Kudos
Reply