Author Topic: Problems with strings and preprocessor directives  (Read 3548 times)

hp

  • Community Member
  • Posts: 31
  • Hero Points: 1
Problems with strings and preprocessor directives
« 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)


Wrong (using preprocessor directives)


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...


SlickEdit Support

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 257
  • Hero Points: 24
Re: Problems with strings and preprocessor directives
« Reply #1 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

hp

  • Community Member
  • Posts: 31
  • Hero Points: 1
Re: Problems with strings and preprocessor directives
« Reply #2 on: July 08, 2009, 06:23:26 am »
Ok, thanks

microcode

  • Community Member
  • Posts: 59
  • Hero Points: 9
Re: Problems with strings and preprocessor directives
« Reply #3 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.

hp

  • Community Member
  • Posts: 31
  • Hero Points: 1
Re: Problems with strings and preprocessor directives
« Reply #4 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.

microcode

  • Community Member
  • Posts: 59
  • Hero Points: 9
Re: Problems with strings and preprocessor directives
« Reply #5 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!

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2357
  • Hero Points: 315
Re: Problems with strings and preprocessor directives
« Reply #6 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.

hp

  • Community Member
  • Posts: 31
  • Hero Points: 1
Re: Problems with strings and preprocessor directives
« Reply #7 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  :)