Author Topic: Code Completion works bad  (Read 6279 times)

Offline tanq

  • Multiple posting newcomer
  • *
  • Posts: 18
Code Completion works bad
« on: October 25, 2010, 03:01:59 pm »
I've upgraded to latest version 6752. However code completion engine fails in many situations.

1. Struct member autocomletion fail even on simpliest structures:
a) Works normal:
Code
struct TEST
{
int a,
int b,
};
TEST t;

b) FAIL: Only "a" member is visible inside t
Code
struct TEST
{
int a,
int b
};
TEST t;

2. Structures from ARM headers aren't visible. Example:
Code
/* "LPC11xx.h" */
typedef struct
{
  __IO uint32_t MOD;                    /*!< Offset: 0x000 Watchdog mode register (R/W) */
  __IO uint32_t TC;                     /*!< Offset: 0x004 Watchdog timer constant register (R/W) */
  __O  uint32_t FEED;                   /*!< Offset: 0x008 Watchdog feed sequence register ( /W) */
  __I  uint32_t TV;                     /*!< Offset: 0x00C Watchdog timer value register (R/ ) */
} LPC_WDT_TypeDef;
#define LPC_WDT               ((LPC_WDT_TypeDef    *) LPC_WDT_BASE   )

Now LPC_WDT-> expands to nothing

3. Functions from math.h and other system libraries doesn't work (but from my file works fine)
Example:
Code
/* <math.h> */
#ifndef __math_68881
extern double atan _PARAMS((double));
extern double cos _PARAMS((double));
extern double sin _PARAMS((double));
extern double tan _PARAMS((double));
extern double tanh _PARAMS((double));
extern double frexp _PARAMS((double, int *));
extern double modf _PARAMS((double, double *));
extern double ceil _PARAMS((double));
extern double fabs _PARAMS((double));
extern double floor _PARAMS((double));
#endif /* ! defined (__math_68881) */

Code completion doesn't understand that.

sprintf, atoi and other functions aren't visible  too.

It seems CC completely unaware of macros. Is it possible to make it work?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code Completion works bad
« Reply #1 on: October 25, 2010, 03:41:22 pm »
Code
struct TEST
{
int a,
int b,
};

Have you tried to replace ',' with ';'? :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline tanq

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Code Completion works bad
« Reply #2 on: October 25, 2010, 03:51:29 pm »
Obviosly, there is an error, I was trying different situations to find out why it not working

What about system headers?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code Completion works bad
« Reply #3 on: October 25, 2010, 04:09:47 pm »
extern declarations are ignored if I remember correctly.
Also, the macro preprocessor is not full featured, just yet.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline tanq

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Code Completion works bad
« Reply #4 on: October 25, 2010, 09:44:44 pm »
Tanks for reply. I tuned parser options to replace "exern" and "_PARAMS" words to whitespace. Now Library funcitons are shown.
Structs from LPC headers still don't work.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code Completion works bad
« Reply #5 on: October 25, 2010, 10:07:37 pm »
Can you provide simple project with one such struct + all the required defines?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline tanq

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Code Completion works bad
« Reply #6 on: October 26, 2010, 12:58:15 pm »
Yes, here it is (20K size) http://ifile.it/6wqf8i2
This is complete project, it builds successfully and works in hardware. Can be used as template for cortex-m0 / cortex-m3 AMRs.
YAGARTO toolchain used to build. Alternatively, CodeSourcery or KGP toolchain can be used. However they will require to edit standart library paths in "linker path" options.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code Completion works bad
« Reply #7 on: October 26, 2010, 04:21:03 pm »
Simple project means: one c or cpp with all needed code, and no external requirements
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline tanq

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Code Completion works bad
« Reply #8 on: October 27, 2010, 03:25:22 pm »
Small extract from the project above. No need for additional headers and defines.
Code
/*  structure declaration demo */
#ifdef __cplusplus
#define     __I     volatile                /*!< defines 'read only' permissions      */
#else
#define     __I     volatile const          /*!< defines 'read only' permissions      */
#endif
#define     __O     volatile                  /*!< defines 'write only' permissions     */
#define     __IO    volatile                  /*!< defines 'read / write' permissions   */
typedef struct
{
__IO uint32_t PCON;                   /*!< Offset: 0x000 Power control Register (R/W) */
__IO uint32_t GPREG0;                 /*!< Offset: 0x004 General purpose Register 0 (R/W) */
__IO uint32_t GPREG1;                 /*!< Offset: 0x008 General purpose Register 1 (R/W) */
__IO uint32_t GPREG2;                 /*!< Offset: 0x00C General purpose Register 2 (R/W) */
__IO uint32_t GPREG3;                 /*!< Offset: 0x010 General purpose Register 3 (R/W) */
__IO uint32_t GPREG4;                 /*!< Offset: 0x014 General purpose Register 4 (R/W) */
} LPC_PMU_TypeDef;
/*@}*/ /* end of group LPC11xx_PMU */
#define LPC_AHB_BASE          (0x50000000UL)
#define LPC_PMU_BASE          (LPC_APB0_BASE + 0x38000)
#define LPC_PMU               ((LPC_PMU_TypeDef    *) LPC_PMU_BASE   )

/* function declaration demo (from math.h) */
#define _PARAMS(paramlist) paramlist
extern double acos _PARAMS((double));

void main(void)
{
LPC_PMU->PCON = 0x20; /* members of LPC_PMU-> are not shown */
((LPC_PMU_TypeDef    *) LPC_PMU_BASE)->PCON = 0x20; /*this is the same, but members of LPC_PMU_TypeDef now visible*/
acos(20.5); /*this autocompletes only if _PARAMS macro substituted in "settings" menu */
}

Offline tanq

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Code Completion works bad
« Reply #9 on: October 30, 2010, 12:03:33 am »
After some additional testing I found that CPP files with classes are handled much better.