SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: hp on July 07, 2009, 02:25:57 pm

Title: Problems with strings and preprocessor directives
Post by: hp on July 07, 2009, 02:25:57 pm
Hey folks

I have a C-project, where I have a problem with code coloring when I combine preprocessor directives with string definitions. I wonder if this is a general Slick problem, or if I have a problem with my config. The following screens are taken directly from Slickedit:

Correct (no preprocessor directives)
(http://www.holdies.ch/fileadmin/user_upload/_temp_/correct.jpg)

Wrong (using preprocessor directives)
(http://www.holdies.ch/fileadmin/user_upload/_temp_/wrong.jpg)

Does anybody know something about this problem? I can compile the version that is being displayed wrong, so I'd say it really is just a displaying problem...

Title: Re: Problems with strings and preprocessor directives
Post by: SlickEdit Support on July 07, 2009, 07:11:33 pm
Hi hp,

It looks as though a Coloring element in SlickEdit is "seeing" this as an Unterminated String. Go to Tools > Options > Appearance > Colors and set the Background Color of "Unterminated String" to White.  I'll make a note in our Dev Tracker about this one.

Thanks,
SlickEdit Support
Title: Re: Problems with strings and preprocessor directives
Post by: hp on July 08, 2009, 06:23:26 am
Ok, thanks
Title: Re: Problems with strings and preprocessor directives
Post by: microcode on July 08, 2009, 05:32:46 pm
I happened to be looking at my options for C/C++ and saw that there is an option called "Trailing backslash continues string across lines".  That option was unchecked for me, so I created a small test file like the one hp posted originally.

With that option turned off, SlickEdit did display the strings as unterminated. But with the option turned on, SlickEdit correctly determined that the strings were properly terminated.  For me, the preprocessor directives had no effect on it. But I'm using the new v14.0.2.1 Release Candidate so perhaps that is why it's a little different for me.

So, hp, try enabling that option to see if it fixes the issue.

I'm not sure why the option was turned off in my case. I don't think I ever unchecked it, so I'm wondering if that is the default setting. For C/C++ the default setting should be to have that option turned on.

Note: there are actually two separate options, one for double-quoted strings and the other for single-quoted strings. See the attached image of the C/C++ Color Coding options.
Title: Re: Problems with strings and preprocessor directives
Post by: hp on August 03, 2009, 02:29:41 pm
Hey Microcode

Sorry that I did not answer sooner, but I was on holiday...

I quickly had a look at that option. For me it was active (at least for the double quote string). Just to check I also activated this behavior for the single quote, but it did not change anything for me.

As you said, might be the different versions, I'm using v14.0.1.2.
Title: Re: Problems with strings and preprocessor directives
Post by: microcode on August 05, 2009, 04:37:29 pm
Too bad that didn't fix the issue for you.

Hope you had a nice holiday, though!
Title: Re: Problems with strings and preprocessor directives
Post by: Dennis on August 06, 2009, 09:39:04 pm
There was an interaction between the coloring for inactive code sections (#if 0) and continuations for multi-line strings that caused this string coloring to break when in a #if block.

I am putting in a fix for this issue for the next major release of SlickEdit.  Unfortunately, this issue is not hot fixable.
Title: Re: Problems with strings and preprocessor directives
Post by: hp on August 11, 2009, 04:03:34 pm
I'm glad you found it. It's not that big of a bother though, so it's no problem if there's no hotfix. Changing the colour setting is working fine meanwhile  :)