-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Feature: C23 improved tag compatibility missing implementation #187
Comments
The idea for this feature is just remove the struct members from struct type. struct X { int i; };
void f(struct X { int i; } x){ } generated code struct X { int i; };
void f(struct X x) {} What is missing is the comparison with the previous tag X. |
Here's an example that I have been plating with:
This should compile with C23. At the moment only gcc trunk supports this. |
There are some details. #define Array(TYPE) struct TYPE##Array {TYPE* elements; int count;}
#pragma expand Array
Array(int);
void foo(Array(int) myArr) {
// do something
}
int main() {
Array(int) myInts;
myInts.elements = (int*) (int[3]) {3, 2, 1};
myInts.count = 3;
foo(myInts);
return 0;
} then the generated code would be ```c
#define Array(TYPE) struct TYPE##Array {TYPE* elements; int count;}
#pragma expand Array
struct intArray {int* elements; int count;};
void foo(struct intArray myArr) {
}
int main() {
struct intArray myInts;
myInts.elements = (int*) (int[3]) {3, 2, 1};
myInts.count = 3;
foo(myInts);
return 0;
} |
Not many compilers (currently only gcc trunk) support C23 improved tag compatibility:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3037.pdf
Some data structures would be easier with this feature supported.
The text was updated successfully, but these errors were encountered: