Author Topic: usercpp.h not work...  (Read 3564 times)

SE_FANS

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
usercpp.h not work...
« on: July 10, 2017, 06:12:45 AM »




Dennis

  • Senior Community Member
  • Posts: 3955
  • Hero Points: 515
Re: usercpp.h not work...
« Reply #1 on: July 10, 2017, 02:43:13 PM »
usercpp.h does not support #include, #if, #elif, etc.  Only #define, #undef, and #delete (to override a built-in define).

I can't make out from your screenshots what you want to happen.  If you want your #include statements to get tagged with the actual path you construct using a macro, you'll need to define the macros (DeviceFamily_constructPath, DeviceFamily_DIRECTORY, and DeviceFamily_ID) in usercpp.h.

SE_FANS

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Re: usercpp.h not work...
« Reply #2 on: July 11, 2017, 02:57:07 AM »
sorry, in usercpp.h  ,defined a string : DeviceFamily_CC13X0; but can't go to definition rf_mailbox.h directly,




Dennis

  • Senior Community Member
  • Posts: 3955
  • Hero Points: 515
Re: usercpp.h not work...
« Reply #3 on: July 11, 2017, 01:42:34 PM »
Please attach your usercpp.h.

SE_FANS

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Re: usercpp.h not work...
« Reply #4 on: July 12, 2017, 08:15:39 AM »
ok, just upload related files also:

Dennis

  • Senior Community Member
  • Posts: 3955
  • Hero Points: 515
Re: usercpp.h not work...
« Reply #5 on: July 12, 2017, 04:31:16 PM »
ok, here's what I found.

1) your usercpp.h doesn't have all the information you would need to expand the macro you want to expand (DeviceFamily_constructPath).  Here is a more complete example:
Code: [Select]
#define DeviceFamily_ID_CC13X0      0x00000100
#define DeviceFamily_ID             DeviceFamily_ID_CC13X0
#define DeviceFamily_DIRECTORY      cc13x0
#define DeviceFamily_constructPath(x) <ti/devices/DeviceFamily_DIRECTORY/x>

2) However, we do not expand macros in #include statements anyway.  I am going to enhance this for the next release of SlickEdit.

3) Here's a helpful hint for the future, when you want to add defines from a #include file, use the "Import..." functionality on the C/C++ Preprocessing dialog.  It will find the all the defines in the file and let you pick which ones you want to add.

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: usercpp.h not work...
« Reply #6 on: July 12, 2017, 06:22:48 PM »
Dennis a couple of quick enhancement ideas:
#1: Offer a way to highlight the recognized macros in a cpp file.
 In View, there are "Line Numbers, Spaces, etc". Add View->Preprocessor macros.
This would highlight only the macros that Slick recognizes and does something with due to usercpp.h

#2: Offer a way to view Slicks preprocessed version of the text file.
Slick applies / expands the macros from Usercpp.h to transform the text in the buffer -- so, show this transformation to the user. Maybe as a side-by-side diff view, or a hoverover popup for each recognized macro.

Dennis

  • Senior Community Member
  • Posts: 3955
  • Hero Points: 515
Re: usercpp.h not work...
« Reply #7 on: July 12, 2017, 06:51:07 PM »
I'll file feature requests about these. 

The first one is relatively simple to implement, but possibly of limited value.  In this example, if you define the top-level macro, it would be highlighted, but you wouldn't be able to see that the next level macro wasn't defined (well, maybe in the hover-over popup, but then we're stuck tracking a lot of stuff that we shouldn't be spending CPU cycles or expending memory to track).

Code: [Select]
#define STUPID_PREPROCESSING MORE_STUPID_PREPROCESING(x)

void STUPID_PREPROCESSING(function_name);

With respect to the preprocessed version of the file and Context Tagging, the most valuable tool to look at that is to look at the Defs tool window.  If something doesn't reflect what you expect there, then you know you still have preprocessing to untangle (or, in an ideal world, eliminate from your code).