The code completion is not working for simple case

General questions regarding the usage of CodeLite
ArtDen
CodeLite Curious
Posts: 5
Joined: Mon Sep 07, 2015 2:58 pm
Genuine User: Yes
IDE Question: C++
Contact:

The code completion is not working for simple case

Post 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
Last edited by ArtDen on Tue Sep 08, 2015 8:55 am, edited 1 time in total.
ArtDen
CodeLite Curious
Posts: 5
Joined: Mon Sep 07, 2015 2:58 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: The code completion is not working for simple case

Post by ArtDen »

Hm... Tried CodeLite on XUbuntu (trusty). It works there
ArtDen
CodeLite Curious
Posts: 5
Joined: Mon Sep 07, 2015 2:58 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: The code completion is not working for simple case

Post by ArtDen »

ArtDen
CodeLite Curious
Posts: 5
Joined: Mon Sep 07, 2015 2:58 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: The code completion is not working for simple case

Post 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
Gibbon1
CodeLite Expert
Posts: 167
Joined: Fri Jul 22, 2011 5:32 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: The code completion is not working for simple case

Post 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.
ArtDen
CodeLite Curious
Posts: 5
Joined: Mon Sep 07, 2015 2:58 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: The code completion is not working for simple case

Post 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.
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: The code completion is not working for simple case

Post 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
Make sure you have read the HOW TO POST thread
Post Reply