-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(cpp) Add additional keywords #2289
Conversation
src/languages/cpp.js
Outdated
'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp ' + | ||
'fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper ' + | ||
'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow ' + | ||
'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp ' + | ||
'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan ' + | ||
'vfprintf vprintf vsprintf endl initializer_list unique_ptr', | ||
'vfprintf vprintf vsprintf endl initializer_list unique_ptr _Bool complex _Complex _Imaginary', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we also have imaginary
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprisingly, no. Those are keywords coming from C99, not all of them have their equivalents in the C++ standard library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I said that because of: https://en.cppreference.com/w/c/numeric/complex/imaginary
double imaginary i = 2.0*I; // pure imaginary
This macro expands to the keyword _Imaginary.
Defined in complex.h... if we don't count both how are we deciding that _Imaginary is a keyword but imaginary is not?
I'm welcome to be wrong here, but I'm trying to understand the logic we're using to call something a keyword.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You didn't respond? Am I thinking about this wrong? ... ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double imaginary i = 2.0*I; // pure imaginary
double _Imaginary i = 2.0*I; // pure imaginary
Given this snippet, wouldn't both cases of imaginary there count as keywords? Yes/no? Or are we drawing a distinction between build-in vs pulled in via some include?
Complex seems to be in the same boat:
https://en.cppreference.com/w/c/language/arithmetic_types#Complex_floating_types
So it seems to me if complex
is a keyword, then imaginary
also should be, and if not, then it should not? Same for bool
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you just want to do the simplest thing to get this PR approved from where I'm setting it seems we need to add imaginary
as a keyword also, and then we're consistent. But fell free to make a case the other way if you think that's not correct.
Also, please add a changelog entry. |
No description provided.