[ 
https://issues.apache.org/jira/browse/MINIFICPP-1306?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marton Szasz resolved MINIFICPP-1306.
-------------------------------------
    Fix Version/s:     (was: 1.0.0)
       Resolution: Later

This is an ongoing change: we're changing whatever headers we touch during 
normal development

> Replace header guards with #pragma once
> ---------------------------------------
>
>                 Key: MINIFICPP-1306
>                 URL: https://issues.apache.org/jira/browse/MINIFICPP-1306
>             Project: Apache NiFi MiNiFi C++
>          Issue Type: Task
>    Affects Versions: 0.7.0
>            Reporter: Adam Hunyadi
>            Priority: Minor
>              Labels: MiNiFi-CPP-Hygiene, starter
>
> *Background:*
> The team decided to replace header guards with {{{color:#403294}{{#pragma 
> once}}{color}}} once. It is not standardized, but all the compilers we 
> support have it, and we already have it scattered in our headers, so we can 
> consider this update safe.
> *Proposal:*
> It should be easy to replace the header guards based on the linter 
> recommendations. Once we have all the linter warnings enabled, [[this 
> function from 
> cpplint]|https://github.com/cpplint/cpplint/blob/1.5.3/cpplint.py#L2286] can 
> be used to find the header guard string and replaced in the 
> {{{color:#403294}{{#ifndef}}{color}}} and 
> {{{color:#403294}{{#define}}{color}}} and matching 
> {{{color:#403294}{{#endif}}{color}}}.
>  # Run linter checks for header guards on all non-thirdparty header files in 
> the project. The linter produces these flags as [build/header_guard].
> {code:bash|title=Example for matching against [build/header_guard] (zsh)}
> (command running linter)  |& grep 'ifndef header guard has wrong style' | 
> egrep -v "^Done processing|^Ignoring" | tr ":" " " | cut -d" " -f1,14 | xargs 
> -n 2 sh -c 'sed -i "" s/$(ggrep -m1 -oP "(?<=\#ifndef ).*" $1)/$2/g $1' sh
>   {code}
>  # Write a similar correction for marking header guards for comments
> {code:bash|title=Example script producing comments on header guard endifs 
> (zsh)}
> (command running linter) |& egrep -v '^Done processing|^Ignoring' | grep 
> "endif line should be" | tr ":" " " | cut -d" " -f1,2,9-12 | xargs -n 3 sh -c 
> 'sed -i "" "$2s;.*;$3;" $1' sh | less
>  {code}
>  # Write a python script calling into the cpplint function producing header 
> guard macro names based on file names, makes an assertion on having exactly 
> three matches and replaces the first one with {{{color:#403294}{{#pragma 
> once}}{color}}} , deletes the other two
>  # Call the script on all non-thirdparty headers
>  # Check the diff produced



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to