Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: mirrorok on August 31, 2020, 12:44:04 pm

Title: Editor's C Dialect
Post by: mirrorok on August 31, 2020, 12:44:04 pm
I have setup my compiler (mingwm) to C dialect ANSI. This is working for me fine. If I e.g. enter a line comment I receive error messages as expected.

But how to setup C89/C90 or whatever dialect to the C-Editor in Code:Blocks? Errors, Syntax-Highlighting ect. should apply to that dialect too in my point of view.

I'm used to Eclipse IDE, when I change to a different Java Version the Editor show up a different behavior.
Title: Re: Editor's C Dialect
Post by: BlueHazzard on August 31, 2020, 01:42:11 pm
Quote
Errors, Syntax-Highlighting ect. should apply to that dialect too in my point of view.
Codeblocks does not have "live error" checking... Is syntax highlighting different with C89/C90 ?
Title: Re: Editor's C Dialect
Post by: mirrorok on August 31, 2020, 02:06:15 pm
Quote
Is syntax highlighting different with C89/C90 ?

I think so, e.g. In-Line-Comments ...

Code
#include <stdio.h>
#include <stdlib.h>

int main()
{
    // Comment
    printf("Hello world!\n");
    return 0;
}

does not compile ...

Code
gcc.exe -Wall -std=c90 -g  -c C:\script\C\Sandbox\main.c -o obj\Debug\main.o
gcc.exe  -o bin\Debug\Sandbox.exe obj\Debug\main.o   
C:\script\C\Sandbox\main.c: In function 'main':
C:\script\C\Sandbox\main.c:6:5: error: C++ style comments are not allowed in ISO C90
     // Comment
     ^

Also the StdLib is different and this should be considered as well.
Title: Re: Editor's C Dialect
Post by: oBFusCATed on August 31, 2020, 07:28:03 pm
The scintilla (the editor library we're using) lexer for C is not separate but it is common for both C and C++. And I'm not sure it has options to specify the dialect for C or C++. If you can set this up in scite or another scintilla based editor (notepad++, geany, codelite) we could probably implement this. But I don't think it is high priority. Also the editor part and the build part aren't really connected, so it would be confusing if you have a c89 project, but open an external c99 or c11 file. What should happen in this case?
Title: Re: Editor's C Dialect
Post by: mirrorok on September 02, 2020, 10:13:02 am
It was more a question if I probably just did not find the option to setup the dialect in CodeBlocks rather than a request for a modify or change. But good to know scintilla is used. Maybe I will find a custom ANSI C lexer somewhere in the future.

Thanks!