Page 1 of 1

The code completion is not working for simple case

Posted: Mon Sep 07, 2015 3:12 pm
by ArtDen
Hi,

I tried to use CodeLite for MCU firmware developing (for STM32's MCUs) and was surprised CodeLite doesn't show suggestions for MCU objects (timers, ports etc). This is simple example made by copypasting of STM32 cmsis headers:

Code: Select all

// code from stm32f10x.h BEGIN
#include <stdint.h>

#define __IO volatile
#define PERIPH_BASE     ((uint32_t)0x40000000)
#define APB1PERIPH_BASE PERIPH_BASE
#define TIM2_BASE       (APB1PERIPH_BASE + 0x0000)

typedef struct
{
  __IO uint16_t CR1;
  uint16_t  RESERVED0;
  __IO uint16_t CR2;
  uint16_t  RESERVED1;
  __IO uint16_t SMCR;
  uint16_t  RESERVED2;
  __IO uint16_t DIER;
  uint16_t  RESERVED3;
  __IO uint16_t SR;
  uint16_t  RESERVED4;
  __IO uint16_t EGR;
  uint16_t  RESERVED5;
  __IO uint16_t CCMR1;
  uint16_t  RESERVED6;
  __IO uint16_t CCMR2;
  uint16_t  RESERVED7;
  __IO uint16_t CCER;
  uint16_t  RESERVED8;
  __IO uint16_t CNT;
  uint16_t  RESERVED9;
  __IO uint16_t PSC;
  uint16_t  RESERVED10;
  __IO uint16_t ARR;
  uint16_t  RESERVED11;
  __IO uint16_t RCR;
  uint16_t  RESERVED12;
  __IO uint16_t CCR1;
  uint16_t  RESERVED13;
  __IO uint16_t CCR2;
  uint16_t  RESERVED14;
  __IO uint16_t CCR3;
  uint16_t  RESERVED15;
  __IO uint16_t CCR4;
  uint16_t  RESERVED16;
  __IO uint16_t BDTR;
  uint16_t  RESERVED17;
  __IO uint16_t DCR;
  uint16_t  RESERVED18;
  __IO uint16_t DMAR;
  uint16_t  RESERVED19;
} TIM_TypeDef;

#define TIM2  ((TIM_TypeDef *) TIM2_BASE)

// code from stm32f10x.h END

int main()
{
	TIM2->CR1 = 0; // the code completion after TIM2-> doesn't show suggestions!

	return 0;
}
I expected code completion working after TIM2-> but it doesn't. How to fix it?

PS: I tried both ctags and clang.
PPS: CodeLite 8.2.0 x86 for Windows

Re: The code completion is not working for simple case

Posted: Tue Sep 08, 2015 8:31 am
by ArtDen
Hm... Tried CodeLite on XUbuntu (trusty). It works there

Re: The code completion is not working for simple case

Posted: Thu Sep 10, 2015 3:40 pm
by ArtDen

Re: The code completion is not working for simple case

Posted: Mon Sep 14, 2015 10:21 pm
by ArtDen
Rebuild doesn't help. Also my file is called main.cpp instead of main.c and c++11 option is switched on for the project

Re: The code completion is not working for simple case

Posted: Tue Sep 15, 2015 3:34 am
by Gibbon1
I'm using codelite for developing on an Freescale ARM processor on windows and similar code completion seems to work for me.

You can try Workspace->Retag Workspace (full), Ive found sometimes clang gets confused.
Also if you move a folder things get confusing because the old clang database still references the old paths

If that doesn't work, might be that clang isn't finding the processor headers files when it reties to index your source code. You could try a hax and reference the header file via an include and see if it works then.

Re: The code completion is not working for simple case

Posted: Tue Sep 15, 2015 8:27 pm
by ArtDen
Gibbon1, for me it is enough to copy/paste the code above into main.cpp to reproduce the problem. So the reason is not in search path for include headers.

Re: The code completion is not working for simple case

Posted: Tue Sep 15, 2015 8:49 pm
by eranif
The above code works for me, however, I suspect that the MinGW versions might be the difference
I am using TDM-GCC 4.9.2 64 bit while you are using 5.1 (?) this might confuse clang

Eran