Author Topic: Function parameters showing up as undefined symbols  (Read 548 times)

joecar

  • Senior Community Member
  • Posts: 385
  • Hero Points: 9
  • engineer/gearhead
Function parameters showing up as undefined symbols
« on: September 11, 2022, 10:02:25 pm »
When I add #if/#endif around some functions, the function parameters show up as undefined symbols.

I'll see if I can post some sanitized code.

Using v27 beta 1 (could not get v27 beta 2 to run).

joecar

  • Senior Community Member
  • Posts: 385
  • Hero Points: 9
  • engineer/gearhead
Re: Function parameters showing up as undefined symbols
« Reply #1 on: September 16, 2022, 06:03:25 pm »
I can't get sanitized code to show the symptom...



joecar

  • Senior Community Member
  • Posts: 385
  • Hero Points: 9
  • engineer/gearhead
Re: Function parameters showing up as undefined symbols
« Reply #2 on: September 16, 2022, 06:05:40 pm »
The unknown symbol highlight occurs when functions and/or structs/arrays are guarded by #if, and appears to not occur when guarded by #ifdef.

joecar

  • Senior Community Member
  • Posts: 385
  • Hero Points: 9
  • engineer/gearhead
Re: Function parameters showing up as undefined symbols
« Reply #3 on: September 16, 2022, 06:12:39 pm »
( and btw, the code guarded by #if is not highlighting as inactive code )

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3794
  • Hero Points: 497
Re: Function parameters showing up as undefined symbols
« Reply #4 on: September 19, 2022, 08:57:30 pm »
C or C++, or another language?  Is the #if outside the entire function, or nested within the function argument list ?

joecar

  • Senior Community Member
  • Posts: 385
  • Hero Points: 9
  • engineer/gearhead
Re: Function parameters showing up as undefined symbols
« Reply #5 on: September 20, 2022, 04:27:49 am »
C

#if is outside the entire function or the entire struct.

Each struct and each function has its own #if X where X is the same.


« Last Edit: September 28, 2022, 04:40:02 pm by joecar »

joecar

  • Senior Community Member
  • Posts: 385
  • Hero Points: 9
  • engineer/gearhead
Re: Function parameters showing up as undefined symbols
« Reply #6 on: September 20, 2022, 10:15:30 pm »
Is there a macro/tool that obfuscates source code to avoid violating proprietary-ness...?
« Last Edit: September 20, 2022, 10:29:10 pm by joecar »

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3794
  • Hero Points: 497
Re: Function parameters showing up as undefined symbols
« Reply #7 on: September 20, 2022, 10:19:16 pm »
Run the command "obfuscate-current-file".  It does a wicked good job.

joecar

  • Senior Community Member
  • Posts: 385
  • Hero Points: 9
  • engineer/gearhead
Re: Function parameters showing up as undefined symbols
« Reply #8 on: September 20, 2022, 10:29:28 pm »
Thanks.

joecar

  • Senior Community Member
  • Posts: 385
  • Hero Points: 9
  • engineer/gearhead
Re: Function parameters showing up as undefined symbols
« Reply #9 on: September 20, 2022, 10:37:33 pm »
See attached obfuscated file...

look at lines 298 (struct) and 397 (function).

This obfuscated file actually shows more unknown symbol highlights that the original.



joecar

  • Senior Community Member
  • Posts: 385
  • Hero Points: 9
  • engineer/gearhead
Re: Function parameters showing up as undefined symbols
« Reply #10 on: September 20, 2022, 11:04:22 pm »
Obfuscated images attached, see unknown symbols (red on yellow).
« Last Edit: September 23, 2022, 05:30:57 pm by joecar »

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3794
  • Hero Points: 497
Re: Function parameters showing up as undefined symbols
« Reply #11 on: September 26, 2022, 08:30:34 pm »
Reproduced. 

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3794
  • Hero Points: 497
Re: Function parameters showing up as undefined symbols
« Reply #12 on: September 27, 2022, 03:49:10 pm »
This bug traces back to the option to handle preprocessing macros defined within the current file.  Document > C/C++ Options > C/C++ Advanced Options >
  • Expand local preprocessing defines. 


This option was working for tagging, as you could see in the Defs tool window that certain symbol definitions were preprocessed out, but it did not apply to the color coding for inactive code regions (#if, etc).  That is why some symbols were flagged as unknown by symbol coloring, because they indeed were preprocessed out by the tagging engine, but color coding still thought that was valid code.  I've added some logic to save those artifacts so that color coding can look for the macro definitions from the current file.

Here is a simple example that reproduces the issue (provided that option is enabled).

Code: [Select]
   #define SI8 0
   int var_before=0;
   #if SI8
      void function_grayed_out(int arg1, int arg2);
   #else
      void function_in_the_middle(int arg3, int arg4);
   #endif
   int var_after=0;

joecar

  • Senior Community Member
  • Posts: 385
  • Hero Points: 9
  • engineer/gearhead
Re: Function parameters showing up as undefined symbols
« Reply #13 on: September 28, 2022, 04:46:35 pm »
Hi Dennis,

Thanks.

I am able to reproduce the issue using your simple code example!

( I checked, that option was already on )