[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kdevelop-bugs
Subject:    [Bug 220445] New: Syntax highlighter does not understand
From:       Perjéssy Lóránt <lostlont () freemail ! hu>
Date:       2009-12-28 19:44:46
Message-ID: bug-220445-40295 () http ! bugs ! kde ! org/
[Download RAW message or body]

https://bugs.kde.org/show_bug.cgi?id=220445

           Summary: Syntax highlighter does not understand conditionally
                    defined macros in read-only header files
           Product: kdevelop
           Version: 3.9.95
          Platform: openSUSE RPMs
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
        AssignedTo: kdevelop-bugs@kdevelop.org
        ReportedBy: lostlont@freemail.hu


Version:           3.9.95 (using KDE 4.3.1)
OS:                Linux
Installed from:    openSUSE RPMs

The 3.9.95 version of KDevelop correctly highlights this code for me:

// --- test.cpp ---

#include <iostream>

#define DEF_CONDITION

#ifdef DEF_CONDITION
#define DEF_VALUE "Hello"
#endif

int main(int argc, char **argv)
{
  std::cout << DEF_VALUE << std::endl;
  return 0;
}

// ---

DEF_VALUE is known here. If I comment out the declaration of DEF_CONDITION the
DEF_VALUE is correctly underlined where I use it. Then after removing the
comment from the declaration the DEF_VALUE macro is known by the highlighter
again.

Though in this form:

// --- header.h ---

#ifdef DEF_CONDITION
#define DEF_VALUE "Hello"
#endif

// --- test.cpp ---

#include <iostream>

#define DEF_CONDITION
#include "header.h"

int main(int argc, char **argv)
{
  std::cout << DEF_VALUE << std::endl;
  return 0;
}

// ---

DEF_VALUE is only recognised by the syntax highlighter if the header.h file was
saved *after* defining DEF_CONDITION in main.cpp. This already involves an
unnecessary "header-resaving" constraint to let the highlighter know about
DEF_VALUE but the problem is insolvable if the .h file is read-only by the
user.

A more concrete example:
I try to use OpenGL extension functions defined in SDL_opengl.h system level
header file but that requires specifying GL_GLEXT_PROTOTYPES before using the
header:

#define GL_GLEXT_PROTOTYPES 1
#include <SDL/SDL_opengl.h>

But the parser skips functions declared conditionally by this macro so it
underlines the functions where I use them.
The compiler works anyway, it's just an annoying thing that I see a lot of code
lines containing underlined expressions though they are correct.

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

_______________________________________________
KDevelop-bugs mailing list
KDevelop-bugs@kdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-bugs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic