[Qt-creator] indent preprocessor directives

Mohammad Mirzadeh mirzadeh at gmail.com
Fri Apr 20 18:59:05 CEST 2012


FYI you need to pass -fopenmp both to the compiler and linker. Also, a
compatible compiler should be used (gcc wroks fine)

On Fri, Apr 20, 2012 at 8:34 AM, Mohammad Mirzadeh <mirzadeh at gmail.com>wrote:

>
>
> On Fri, Apr 20, 2012 at 7:44 AM, Erik Verbruggen <erik.verbruggen at me.com>wrote:
>
>>
>> On Apr 20, 2012, at 2:41, Mohammad Mirzadeh wrote:
>>
>> > Hey guys,
>> >
>> > Is there a way to tell QtCreator to indent directives appropriately? I
>> don't seem to find an option under the code style ...
>>
>> No, there are no options for the preprocessor directives. Qt Creator will
>> put a # at the start of the line, which is what the C(++) standard(s)
>> require.
>>
>> > I need this for better readability of my OpenMP codes where parallel
>> sections should be placed between codeblocks preceded by a compiler
>> directive.
>>
>>
>  > Can you give an example? I have never seen OpenMP code, so I cannot
> guess what "appropriate" means in that context.
>
> Sure. OpenMP is mostly compiler directives that you include in your
> sequential code. A simple Hello world code looks like this
>
> #include <iostream>
>
> #include <omp.h>
>
>
> using namespace std;
>
>
> int main()
>
> {
>
> #pragma omp parallel
>
>     {
>
>         cout << "Hello world from thread # " << omp_get_thread_num() << endl;
>
>     }
>
>     return 0;
>
> }
>
>
> And so what I need is to indent #pragma directive to the proceeding code
> block level. There could also be nested parallel constructs as well which
> hurts the code readability a little bit.
>
>
>> -- Erik.
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20120420/e0dc2c0f/attachment.html>


More information about the Qt-creator mailing list