- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The _Generic keyword is a C11 feature that does not seem available in Intel compilers. It would allow better implementation of object-oriented code in C. Do you plan to support it in the next releases ?
typedef struct { int size; double *data; } VectorDouble;
typedef struct { int size; int *data; } VectorInt;
#define alloc(a, n) _Generic((a), VectorDouble: alloc_VectorDouble(&a, n), VectorInt: alloc_VectorInt(&a, n)) #define release(a) _Generic((a), VectorDouble: release_VectorDouble(a), VectorInt: release_VectorInt(a)) #define at(a, i) _Generic((a), VectorDouble: a.data) void alloc_VectorDouble(VectorDouble *a, int n) { a->data = (double*) malloc(n * sizeof(double)); } void free_VectorDouble(VectorDouble a) { free(a.data); }
void alloc_VectorInt(VectorInt *a, int n) { a->data = (int*) malloc(n * sizeof(int)); } void free_VectorInt(VectorInt a) { free(a.data); }
int main (int argc, char const *argv[]) { const int n = 8; VectorDouble a; VectorDouble b; VectorDouble c; alloc(a, n); alloc(b, n); alloc(c, n); for(int j = 0; j < n; ++j) { at(a, j) = at(b, j) + at(c, j); } release(a); release(b); release(c); return 0; }
Best regards,
Francois
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nice to hear that.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Melanie, I've noted the tracker id and will update this post as and when the release with the fix is out. Velvia, appreciate your patience till then
_Kittur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regretfully, I have to report that DPD200250282 is not on track for the next major release. I'll modify/delete my previous post. Best, Melanie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Velvia,
Since the feature support will not be in the next major release you will have to try to work on your OOP without the __generic keyword for now :-( I'll keep you updated as and when the support with the release is out. Appreciate your patience till then.
_Kittur

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page