cancel
Showing results for 
Search instead for 
Did you mean: 

C file not recognizing #define

joemccarr
Senior
Posted on December 09, 2016 at 13:36

My IDE has a feature that uses less contrasting text for code that is 'inactive' (not included)

 from this I found that some code is not being included that i had expected to be.

 

For instance stm32f0xx_ll_tim.c   &sharpincludes stm32f0xx_ll_tim.h,  which in itself &sharpincludes stm32f0xx.h, which &sharpincludes stm32f030x8.h  which &sharpdefines TIM3. There is a line in stm32f0xx_ll_tim.c that reads ...

 &sharpif defined (TIM1) || defined (TIM2) || defined (TIM3)

  {

      then do this

  }

 

 but the 'then do this' code is not highlighted

 I would of thought stm32f0xx_ll.c would know of TIM3 existance because of the

 nested includes but it doesnt.

 

 Am I missing something?

#c-language
10 REPLIES 10
Amel NASRI
ST Employee
Posted on December 09, 2016 at 15:19

Hi

McCarron.Joseph

‌,

1- Do you have any compilation issue?

2- Is there any expected behavior not working?

3- Are you using a particular Cube example? If yes, which one?

-AMel-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Posted on December 09, 2016 at 16:35

The 

#include stm32f0xx.h looks for an stm32f0xx_conf.h file in your project with a lot of selective defines about what is and isn't pulled in.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
joemccarr
Senior
Posted on December 09, 2016 at 17:01

I am not using the hal drivers just the  low level (LL drivers).

My problem is functions in stm32f0xx_ll_tim.c are not getting pulled in. They should because

stm32f0xx_ll_time.c  #includes stm32fxx_ll_tim.h which #includes 'stm32f0xx.h' which  defines

stm32f030x8 and  #includes 'stm32f030x8.h' in which TIM3 is defined.

So stm32f0xx_ll_tim.c should know TIM3 is defined, but it doesn't.

Wierd, because the program compiles but the functions do not end up modifying registers or doing

what they are suppose to do. You would think I would get errors, not found, not defined whatever.

When i am editing and right click the editor can find the declaration but not the implentation. That

gives me a clue as the function itself is not being rolled in to the program.

Posted on December 09, 2016 at 17:22

 ,

 ,

Well '

♯ if defined (TIM1) || defined (TIM2) || defined (TIM3)

' type constructs aren't going to stop things compiling, just jettison a lot of code that might stop in compiling. If the linkage succeeded enough function body code was supplied to get closure.

At this point you are going to need to walk the code to understand why certain things aren't getting defined, or use some static analysis tools to do it, ie ,

https://scitools.com/

 ,

There is usually a ♯ ifdef at the top of the include files that jettisons the entire content, I'd look at those first.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
shingadaddy
Senior
Posted on December 09, 2016 at 20:31

Gads...This sound like a question I had when using TrueStudio. Turns out if you edit something in an active session, Id get results like that. Hightlighting ( and SEARCH for that matter) were all fouled up. Turns out TS only SCANS the code for this auto highlighting, including, defining, and jumping from function to function or anywhere else in the project only at IMPORT time. Have you tried just closing the whole thing then re-opening it as NEW. ?

joemccarr
Senior
Posted on December 10, 2016 at 19:18

So I got the project to compile and run successfully.

I had to comment out defines that the compiler could not reconcile.

Although it should of been able to.

It seemed the problem came from using nested includes. If what the compiler

needed was in a nested include statement it had problems finding it.

So to just move on I commented out  the '#if XXXXX defined' statements so that

all the code was accessible to the compiler. I know this isn't the right thing to do.

I set up the same project in True Studio and I did not have the problem.

As far as functions returning nothing as I posted before, that was my bad

The ADC enable statement should come AFTER  the assignment to struct members, not before.

So registers were not set up correctly. LOL

Thanks for your help everyone, I appreciate it.

BTW - I think the LL drivers are pretty good way to go and are completely independent of

anything HAL.

AvaTar
Lead
Posted on December 10, 2016 at 19:51

It DID stop things from compiling because I had the IDE telling me things were THERE ( the code was NOT greyed out) when in fact it wasn't.

You obviously have an Eclipse-based IDE. It uses it's own parser for such things, and NOT the target compiler. They tend to disagree from time to time ...

One of the reasons I don't like Eclipse.

shingadaddy
Senior
Posted on December 10, 2016 at 20:01

Guilty.... But feel free to nudge me in a different direction. I'm not married to it. Just the 'no code size limits' and the price of FREE really seem to matter to the bosses here. I came here from a much Much MUCH more simplistic dev environment so all these new toy -- er uh TOOLS are mind boggling to me. Well and I'm OLD.... That doesn't help.

Posted on December 10, 2016 at 19:27

Good. Glad your moving forward again. Yeah my HILIGHTING problem arose from the opposite of clive1's perspective. It DID stop things from compiling because I had the IDE telling me things were THERE ( the code was NOT greyed out) when in fact it wasn't. These IDE's are nice and fancy but now you have to keep an eye on how *they* trip you up, along with how I trip myself up in my code. Simple is still good.