MPLAB-X Live Pre-Processor of Macros in Code Editor not update / working correclty

196 views
Skip to first unread message

Peter Hollands

unread,
Jan 18, 2016, 8:56:37 AM1/18/16
to uavdevboard
This post is primarily for developers using MPLAB-X:-

Recently Leonardo posted about his concern that code in console.c was being greyed out by the editor in MPLAB-X when the console uart was set 2; but the code should have shown as active.

I spent some time making some test code to try and understand the problem, and then recorded a screencast to show the whole problem. (10 minutes).

I have then posted a thread on the MPLAB-X IDE forum at microchip linking (with difficulty) to the code and screencast. 

If anyone else has constructive comments about this issue with MPLAB-X please discuss them either here on this forum or the microchip site.

Best wishes, Pete


Mark Whitehorn

unread,
Jan 18, 2016, 11:24:39 AM1/18/16
to uavdevboard
I'm afraid my comment isn't constructive (as you foresaw) but in my observation it is a waste of effort to post on the Microchip forums. It also seems to be impossible for any C/C++ IDE to parse all the C macros and headers and get the same results as the compiler. While the greyed-out text *may* mean that a macro is undefined, it also might mean that the IDE just couldn't find it in the right context. My experience with IDEs includes Eclipse, Netbeans, MPLAB-X, IntelliJ, and QtCreator. Unless I'm programming in Java, I'm frequently forced to resort to brute-force text searches to find symbol (usually C macro) definitions in all of them. IIRC, MPLAB-X is built on an outdated version of Eclipse.

--
--
---
You received this message because you are subscribed to the Google Groups "uavdevboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavdevboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Leonardo Garberoglio

unread,
Jan 18, 2016, 11:55:07 AM1/18/16
to uavde...@googlegroups.com
Thank Petern for worry about this issue, is very hard to follow the code (for a begenier, like me) with this issue. I hope we could finde a workaround for this.

bw, Leo

Tom Pittenger

unread,
Jan 18, 2016, 4:24:42 PM1/18/16
to uavdevboard

Mplab x is based on NetBeans. Is net beans based on eclipse? I thought it was separate.

Peter Hollands

unread,
Jan 18, 2016, 4:38:58 PM1/18/16
to uavdevboard
The latest versions of MPLAB-X (v 3.15 and 3.2) are based on Netbeans 8.x . (Prior to that it was version 7.x).   Yes, Eclipse is a different product.
Mark's main point was that interactive editors have a hard time replicating all the logic of the C pre-processor in real time as code is developed.

Mark Whitehorn

unread,
Jan 18, 2016, 5:24:31 PM1/18/16
to uavdevboard
Thanks Tom and Pete. Faulty memory on my part. I remember wishing MPLAB-X had kept up to date because (I think) it didn't have integrated git support with Netbeans 7.
And if you find an IDE which understands C/C++ scopes, namespaces. preprocessor substitutions and syntactical oddities any better than I (very low bar there), please let me know :)

Robert Dickenson

unread,
Jan 18, 2016, 8:12:29 PM1/18/16
to uavdevboard
I've found Visual Studio typically does a very good job of getting it right, as I use it during my SILSIM development work under Windows.

Leo, if you find an IDE getting its syntax hightlighting suspicious and misleading you during development, may I suggest turning the feature off entirely and doing things the 'old fashioned' way. Due to how the MatrixPilot include hierarchy is structured macro definitions can sometimes go astray, particularly during re-factoring work - so I sometimes find myself adding temporary "#pragma error" statements to the code in order to ensure what I think is happening, actually is (-;

Peter Hollands

unread,
Jan 22, 2016, 3:16:03 PM1/22/16
to uavdevboard
Well I've found one workaround; which is how to switch off the pre-processor formatting in MPLAB-X entirely.
In that way I am not misled when the live pre-processor logic is incorrect in it's highlighting of inactive pre-processor blocks.
The option is well hidden. 

MPLAB-X / Preferences  / Fonts and Colours / 
Select Syntax
Select Language as C
Select "Inactive Processor Block"
Select Foreground to be "Inherited"
Restart mplab-x and all code will show as normal highlighting regardless of whether the preprocessor block is active or not.

I enclose a screenshot.

Best wishes, Pete

Screen Shot 2016-01-22 at 19.05.36.png
Reply all
Reply to author
Forward
0 new messages