packcc icon indicating copy to clipboard operation
packcc copied to clipboard

reserved identifier violation

Open elfring opened this issue 6 years ago • 14 comments

I would like to point out that identifiers like “PCC_INCLUDED__” and “STRING_FLAG__IDENTIFIERdo eventually not fit to the expected naming convention of the C++ language standard. Would you like to adjust your selection for unique names?

elfring avatar Nov 02 '19 10:11 elfring

Thank you for your advice. I replaced every double underscore __ with a single underscore if it is in an identifier that consists of uppercase letters and underscores. Please check out the branch 'develop'.

arithy avatar Nov 02 '19 16:11 arithy

Thanks for your renaming of affected identifiers.

:crystal_ball: Can a name selection trigger any corresponding software development concerns?

elfring avatar Nov 03 '19 09:11 elfring

How do you think about to rename also functions?

elfring avatar Nov 03 '19 09:11 elfring

How do you think about to rename also functions?

I don't want to rename them anymore. I determined the function naming convention like 'class name'__'method name' to distinguish it plainly from other word delimiters '_'.

Can a name selection trigger any corresponding software development concerns?

Sorry, I couldn't understand what you mean. Could you express it more simply?

arithy avatar Nov 03 '19 22:11 arithy

I don't want to rename them anymore.

This implementation detail can be fine according to the naming convention for the programming language “C”. Can anybody get concerned about remaining risks for undefined behaviour if contents from C files will be treated as C++ source code anyhow?

Could you express it more simply?

Is there a possibility that an identifier will be constructed (together with the prefix “PCC_INCLUDED_”) that does not result in an acceptable include guard?

elfring avatar Nov 04 '19 07:11 elfring

Identifiers ending with "_t" are also reserved in C++. I see many instances of this in packcc, even in the develop branch. https://stackoverflow.com/a/228797/

I also see "__pcc_in", "__pcc_out", and "__pcc_ctx" in the develop branch, all of which C++ considers to be reserved identifiers due to the leading double underscores.

As @elfring says, C++ has stricter rules than C regarding which identifiers are considered reserved.

MaxBarraclough avatar Dec 14 '19 23:12 MaxBarraclough

Is this a parser generator for C or C++?

audinue avatar Jul 19 '22 15:07 audinue

Just for C. You can use it with a C++ compiler, but I don't support such usage.

arithy avatar Jul 19 '22 21:07 arithy

Why @elfring asked you to comply with C++ language standard then?

audinue avatar Jul 20 '22 03:07 audinue

Just because @elfring wanted to use PackCC with C++, I think. I accepted a part of @elfring's suggestion since I thought it had better comply with C++ standard as much as possible. Anyway, I can close this issue if I strictly stand on the specification: just for C.

arithy avatar Jul 20 '22 04:07 arithy

@elfring, @MaxBarraclough, I'm going to close this issue because of the following reasons:

  • PackCC generates a C source code in a .c file (not in a file with the C++ extension such as .cpp).
  • PackCC generates a C header file that can be included from C++ source files with no problem.
  • I strongly disagree too vast the identifier pattern that POSIX claims to reserve.

If you have any objection against closing this issue, let me know by the end of this month (Aug. 2022).

arithy avatar Aug 09 '22 22:08 arithy

:thought_balloon: I became curious if interests could grow further for involved standard compliance aspects.

elfring avatar Aug 10 '22 07:08 elfring

thought_balloon I became curious if interests could grow further for involved standard compliance aspects.

Why not putting some ads on Youtube instead of violating the scope of this project?

audinue avatar Aug 10 '22 09:08 audinue

Some development concerns can be tackled together for the programming languages “C” and “C++”, can't they?

elfring avatar Aug 10 '22 10:08 elfring

I became curious if interests could grow further for involved standard compliance aspects.

It might be just your impression, and isn't persuasive.

Some development concerns can be tackled together for the programming languages “C” and “C++”, can't they?

I never deny using C and C++ together. I already wrote "PackCC generates a C header file that can be included from C++ source files with no problem". The generated C code is callable from C++ codes.

arithy avatar Aug 14 '22 01:08 arithy