Cytnx icon indicating copy to clipboard operation
Cytnx copied to clipboard

Change header guard to use #pragma once

Open kaihsin opened this issue 1 year ago • 9 comments

kaihsin avatar Sep 14 '24 00:09 kaihsin

There are some decisions from the coding style guides.

To summarise, prefer header guards to #pragma once. The former is supported by the standard and is more portable.

IvanaGyro avatar Sep 14 '24 17:09 IvanaGyro

Are we following Google coding style now?

On Sat, Sep 14, 2024, 13:55 Ivana @.***> wrote:

There are some decisions from the coding style guide.

  • https://google.github.io/styleguide/cppguide.html#The__define_Guard

https://google.github.io/styleguide/cppguide.html#Nonstandard_Extensions

http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf8-use-include-guards-for-all-header-files

To summarise, prefer header guards than #pragma once. The former is supported by the standard and is more portable.

— Reply to this email directly, view it on GitHub https://github.com/Cytnx-dev/Cytnx/issues/470#issuecomment-2351084231, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCX3SOZISHJ3FRHZMJYZM3ZWR2BXAVCNFSM6AAAAABOGJ4JROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJRGA4DIMRTGE . You are receiving this because you authored the thread.Message ID: @.***>

kaihsin avatar Sep 14 '24 19:09 kaihsin

If so I would like to have a pre-commit tool in place for this. If not, lets keep it with c++ std guide recommentation up to the version we are targeting as long as it comply with clang-format. Other than that I don't think we should focus on those fomat too much

On Sat, Sep 14, 2024, 15:51 Kai-Hsin Wu @.***> wrote:

Are we following Google coding style now?

On Sat, Sep 14, 2024, 13:55 Ivana @.***> wrote:

There are some decisions from the coding style guide.

  • https://google.github.io/styleguide/cppguide.html#The__define_Guard

https://google.github.io/styleguide/cppguide.html#Nonstandard_Extensions

http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf8-use-include-guards-for-all-header-files

To summarise, prefer header guards than #pragma once. The former is supported by the standard and is more portable.

— Reply to this email directly, view it on GitHub https://github.com/Cytnx-dev/Cytnx/issues/470#issuecomment-2351084231, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCX3SOZISHJ3FRHZMJYZM3ZWR2BXAVCNFSM6AAAAABOGJ4JROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJRGA4DIMRTGE . You are receiving this because you authored the thread.Message ID: @.***>

kaihsin avatar Sep 15 '24 05:09 kaihsin

Are we following Google coding style now?

It seems that, yes.

https://github.com/Cytnx-dev/Cytnx/blob/f43dcbd960b955611cddcbc036cc07e113dbbb8b/.clang-format#L1

We also have pre-commit settings

https://github.com/Cytnx-dev/Cytnx/blob/f43dcbd960b955611cddcbc036cc07e113dbbb8b/.pre-commit-config.yaml

CC @jeffry1829

IvanaGyro avatar Sep 15 '24 05:09 IvanaGyro

Does it actually settled up on action? I thought its there. And it was fine before tho, so I am confused

On Sun, Sep 15, 2024, 01:22 Ivana @.***> wrote:

Are we following Google coding style now?

It seems that, yes.

https://github.com/Cytnx-dev/Cytnx/blob/f43dcbd960b955611cddcbc036cc07e113dbbb8b/.clang-format#L1

We also have pre-commit settings

https://github.com/Cytnx-dev/Cytnx/blob/f43dcbd960b955611cddcbc036cc07e113dbbb8b/.pre-commit-config.yaml

CC @jeffry1829 https://github.com/jeffry1829

— Reply to this email directly, view it on GitHub https://github.com/Cytnx-dev/Cytnx/issues/470#issuecomment-2351379982, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCX3SJI4B7TI7XURG3HDBDZWUKRXAVCNFSM6AAAAABOGJ4JROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJRGM3TSOJYGI . You are receiving this because you authored the thread.Message ID: @.***>

kaihsin avatar Sep 15 '24 05:09 kaihsin

If it's optional requirements for format I'd say we don't worry about it and follow as much as std. Google style is good but it has too much historical burdens

On Sun, Sep 15, 2024, 01:28 Kai-Hsin Wu @.***> wrote:

Does it actually settled up on action? I thought its there. And it was fine before tho, so I am confused

On Sun, Sep 15, 2024, 01:22 Ivana @.***> wrote:

Are we following Google coding style now?

It seems that, yes.

https://github.com/Cytnx-dev/Cytnx/blob/f43dcbd960b955611cddcbc036cc07e113dbbb8b/.clang-format#L1

We also have pre-commit settings

https://github.com/Cytnx-dev/Cytnx/blob/f43dcbd960b955611cddcbc036cc07e113dbbb8b/.pre-commit-config.yaml

CC @jeffry1829 https://github.com/jeffry1829

— Reply to this email directly, view it on GitHub https://github.com/Cytnx-dev/Cytnx/issues/470#issuecomment-2351379982, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCX3SJI4B7TI7XURG3HDBDZWUKRXAVCNFSM6AAAAABOGJ4JROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJRGM3TSOJYGI . You are receiving this because you authored the thread.Message ID: @.***>

kaihsin avatar Sep 15 '24 05:09 kaihsin

Client-side git hooks do not sync between git clients. Every client has to install the hook on their own. Here is a section of the document written by @hunghaoti


  1. Use the pre-commit tool to check the coding style:

    (1). If you have not installed the pre-commit tool, you can install it by the command:

    conda install pre-commit
    

    (2). Then you can run the following command to fix the coding style:

    pre-commit run --all-files
    

    You can run twice to make sure all of them are passed.

IvanaGyro avatar Sep 15 '24 05:09 IvanaGyro

Yes I know. We set up this. My point is if there is no issue with clang formatter then I don't think we should care about the format even it stated in Google style. In general as long as there is a guard in action to PR there (which we setup in action) beyond that norm I don't want to put focus on making style happy. We should focus on other more important issues

On Sun, Sep 15, 2024, 01:50 Ivana @.***> wrote:

Client-side git hooks do not sync between git clients. Every client has to install the hook on their own. Here is a section of the document written by @hunghaoti https://github.com/hunghaoti

Use the pre-commit tool to check the coding style:

(1). If you have not installed the pre-commit tool, you can install it by the command:

conda install pre-commit

(2). Then you can run the following command to fix the coding style:

pre-commit run --all-files

You can run twice to make sure all of them are passed.

— Reply to this email directly, view it on GitHub https://github.com/Cytnx-dev/Cytnx/issues/470#issuecomment-2351389967, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCX3SNTNNHQRWCRYAOW7P3ZWUNZDAVCNFSM6AAAAABOGJ4JROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJRGM4DSOJWG4 . You are receiving this because you authored the thread.Message ID: @.***>

kaihsin avatar Sep 15 '24 05:09 kaihsin

Feel free to close this issue if you think we are going to stick with Google style.

On Sun, Sep 15, 2024, 01:54 Kai-Hsin Wu @.***> wrote:

Yes I know. We set up this. My point is if there is no issue with clang formatter then I don't think we should care about the format even it stated in Google style. In general as long as there is a guard there (which we setup in action) beyond that norm I don't want to put focus on making style happy. We should focus on other more important issues

On Sun, Sep 15, 2024, 01:50 Ivana @.***> wrote:

Client-side git hooks do not sync between git clients. Every client has to install the hook on their own. Here is a section of the document written by @hunghaoti https://github.com/hunghaoti

Use the pre-commit tool to check the coding style:

(1). If you have not installed the pre-commit tool, you can install it by the command:

conda install pre-commit

(2). Then you can run the following command to fix the coding style:

pre-commit run --all-files

You can run twice to make sure all of them are passed.

— Reply to this email directly, view it on GitHub https://github.com/Cytnx-dev/Cytnx/issues/470#issuecomment-2351389967, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCX3SNTNNHQRWCRYAOW7P3ZWUNZDAVCNFSM6AAAAABOGJ4JROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJRGM4DSOJWG4 . You are receiving this because you authored the thread.Message ID: @.***>

kaihsin avatar Sep 15 '24 06:09 kaihsin