Click here to Skip to main content
15,892,072 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Structure containing byte[1] as member variable Pin
Chris Losinger5-Sep-12 11:51
professionalChris Losinger5-Sep-12 11:51 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell6-Sep-12 8:31
jschell6-Sep-12 8:31 
GeneralRe: Structure containing byte[1] as member variable Pin
Chris Losinger6-Sep-12 9:19
professionalChris Losinger6-Sep-12 9:19 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell13-Sep-12 8:07
jschell13-Sep-12 8:07 
GeneralRe: Structure containing byte[1] as member variable Pin
Chris Losinger13-Sep-12 8:11
professionalChris Losinger13-Sep-12 8:11 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell14-Sep-12 8:41
jschell14-Sep-12 8:41 
GeneralRe: Structure containing byte[1] as member variable Pin
Stefan_Lang5-Sep-12 1:57
Stefan_Lang5-Sep-12 1:57 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell5-Sep-12 11:26
jschell5-Sep-12 11:26 
Stefan_Lang wrote:
Calling it an idiom may be misleading - it may be commonly used, but it is most
certainly not a recommended practice, and technically not even supported by the
standard.


First part is an opinion but feel free to substantiate it.

Second part there is nothing in ANSI C prior to C99 that disallows it, and except for unusual uses is in specifically defined. And more than that C99 specifically allows for 'flexible array structure' to explicitly define the behavior. See the following link and search for 'flexible' (and note that that that compiler actually extends the support for the type.)

http://pic.dhe.ibm.com/infocenter/lnxpcomp/v121v141/index.jsp?topic=%2Fcom.ibm.xlcpp121.linux.doc%2Flanguage_ref%2Fstrct.html[^]

Stefan_Lang wrote:
in C++, there are much better ways to create dynamic arrays. In fact you have
to look no further than std::vector .


Yep - in C++. But not in C.

Stefan_Lang wrote:
In any case, you have to be very careful about allocating and deallocating


Yes. Just as you must be careful about anything involving pointers and memory in C/C++. But that doesn't have anything to do with what I said.

Stefan_Lang wrote:
but it's also possible to define an instance of that type on the stack instead
if you know the required size at compile time.


Except that is exactly the point - it isn't known at compile time. And moreover, if it was known at compile time they you could create it dynamically as well.

So what does any of that have to do with creating it dynamically or on the stack?
GeneralRe: Structure containing byte[1] as member variable Pin
Stefan_Lang6-Sep-12 2:53
Stefan_Lang6-Sep-12 2:53 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell6-Sep-12 8:28
jschell6-Sep-12 8:28 
AnswerRe: Structure containing byte[1] as member variable Pin
Richard MacCutchan4-Sep-12 9:07
mveRichard MacCutchan4-Sep-12 9:07 
GeneralRe: Structure containing byte[1] as member variable Pin
Rahul from Poona4-Sep-12 20:00
Rahul from Poona4-Sep-12 20:00 
GeneralRe: Structure containing byte[1] as member variable Pin
Richard MacCutchan4-Sep-12 21:46
mveRichard MacCutchan4-Sep-12 21:46 
AnswerRe: Structure containing byte[1] as member variable Pin
jschell4-Sep-12 11:46
jschell4-Sep-12 11:46 
QuestionFinding crash information using the MAP file in vs2005 Pin
neha_soni4-Sep-12 1:10
neha_soni4-Sep-12 1:10 
AnswerRe: Finding crash information using the MAP file in vs2005 Pin
David Crow4-Sep-12 2:35
David Crow4-Sep-12 2:35 
AnswerRe: Finding crash information using the MAP file in vs2005 Pin
krmed4-Sep-12 3:33
krmed4-Sep-12 3:33 
AnswerRe: Finding crash information using the MAP file in vs2005 Pin
Stephen Hewitt6-Sep-12 21:46
Stephen Hewitt6-Sep-12 21:46 
Question(SOLVED) make single executable file in vs2008 (MFC) Pin
jawadali4773-Sep-12 1:26
jawadali4773-Sep-12 1:26 
AnswerRe: make single executable file in vs2008 (MFC) Pin
pasztorpisti3-Sep-12 2:05
pasztorpisti3-Sep-12 2:05 
GeneralRe: make single executable file in vs2008 (MFC) Pin
jawadali4774-Sep-12 17:42
jawadali4774-Sep-12 17:42 
GeneralRe: make single executable file in vs2008 (MFC) Pin
pasztorpisti4-Sep-12 23:04
pasztorpisti4-Sep-12 23:04 
GeneralRe: make single executable file in vs2008 (MFC) Pin
jawadali4779-Sep-12 17:45
jawadali4779-Sep-12 17:45 
GeneralRe: make single executable file in vs2008 (MFC) Pin
pasztorpisti9-Sep-12 21:26
pasztorpisti9-Sep-12 21:26 
GeneralRe: make single executable file in vs2008 (MFC) Pin
jawadali47710-Sep-12 17:17
jawadali47710-Sep-12 17:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.