Skip to main content
10 events
when toggle format what by license comment
Mar 29, 2023 at 1:07 comment added Sangjun Lee @MarkRansom, I am trying to parallelize my C program via CUDA. I have searched for a while (like a week), but there seems to no way to activate C99 feature by the nvcc compiler. The thing is, the multi-dimensional array only appears in the I/O part of my code, therefore in fact GPU never will use multi-dimensional array. But still, I was unable to compile my code via nvcc, and as these multi-dimensional arrays are not critical to the code performance and mainly for the cosmetics in the way of delaring arrays (I think double pointers are ugly), I ended up just flattening those into 1D array.
Mar 28, 2023 at 12:29 comment added Mark Ransom @SangjunLee sometimes C++ compilers that are also C compilers will provide C features to C++ as an extension. Unfortunately using those extensions makes your code non-portable and gets you yelled at on S.O.
Mar 28, 2023 at 6:16 comment added Sangjun Lee Here I found the sentences that I needed to know - " C99 allows for real multidimensional arrays allocated on the heap with dimensions defined at run time, and C++17 still does not come close to what C99 allows"... I was using C99 and now new to C++ and was wondering dynamic allocation of 2D array in C++ is why this controversial... it seems that it is kind of a nature of C++
Dec 1, 2020 at 2:35 comment added Peter Cordes re: cmaster's point about C99: Malloc a 2D array in C / Freaky way of allocating two-dimensional array?. That depends on VLA support, and if you have that as a C++ extension, this answer shows that there's an equivalent with new instead of new[] - apparently new[] not supporting variable dimensions was the problem). Note that new int [var][CONST] does already work in ISO C++.
Apr 25, 2017 at 14:35 comment added cmaster - reinstate monica What's bugging me even more is how far C++ is behind C in this: C99 allows for real multidimensional arrays allocated on the heap with dimensions defined at run time, and C++17 still does not come close to what C99 allows...
Dec 18, 2016 at 14:21 comment added Oliver it's funny how the whole development automation was slept in. Now the only easy out of the box advantage is java. I would really like c++ to take a leap, it has been a mighty and powerful language since ever... why having a lightsaber if you don't use it!
Dec 18, 2016 at 4:20 comment added Mark Ransom @OliverStutz that's the danger of being first. The most recent C++ standards have been trying desperately to make things less burdensome, my favorite is the auto keyword. I'm surprised they haven't tried to tackle 2D arrays, especially since Boost has already shown the way.
Dec 18, 2016 at 1:26 comment added Oliver I might just add, i find this the best solution but i guess for some people it needs a lot of brain to understand all the steps, especially for beginners... ;)! I see 80% of C++ programmers fail when they see typedef'ed stuff.
Dec 18, 2016 at 0:38 comment added Oliver I understand your argument, i personally don't understand why it has to be so difficult, honestly this is the reason why we lose so many programmers to Java, there it just works out of the box! These are base features which make c++ guys lose time!
Jun 2, 2009 at 16:18 history answered Mark Ransom CC BY-SA 2.5