Bug 263913

Summary: KDevelop must create pragma once with include guards
Product: [Applications] kdevelop Reporter: Denis Pesotsky <denis>
Component: Language Support: CPP (old)Assignee: kdevelop-bugs-null
Status: RESOLVED INTENTIONAL    
Severity: wishlist CC: maty78485
Priority: NOR    
Version: unspecified   
Target Milestone: 4.2.0   
Platform: unspecified   
OS: Unspecified   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Denis Pesotsky 2011-01-21 19:44:55 UTC
Version:           unspecified (using KDE 4.5.5) 
OS:                unspecified

When I create class for C/C++ with Project Manager's "Create Class", it creates header with include guards.

But it will be nice, if it will also add pragma once there.

Reproducible: Didn't try

Steps to Reproduce:
Create Class with project manager.

Actual Results:  
Header will look like:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

class MainWindow
{

};

#endif // MAINWINDOW_H

Expected Results:  
Will be nice if header will look like:
#pragma once
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

class MainWindow
{

};

#endif // MAINWINDOW_H
Comment 1 Andreas Pakulat 2011-01-21 22:17:25 UTC
Why? Apart from this being _very_ compiler-specific as opposed to the include-guards I don't see a reason for doing both. The compiler that does know pragma's can work just fine with include-guards as well - afaik.
Comment 2 Denis Pesotsky 2011-01-21 22:53:16 UTC
> The compiler that does know pragma's can work just fine with include-guards as well

Did not know that. You mean, that all popular compilers (including gcc, vcc etc) support include guards optimisation if they have pragma once support?
Comment 3 maty78485 2021-12-05 16:55:22 UTC
I would give the user a choice - whether to use `#pragma once` or `#ifndef / #define` include guards.