Skip to main content
zadane's user avatar
zadane's user avatar
zadane's user avatar
zadane
  • Member for 10 years, 9 months
  • Last seen more than a month ago
awarded
awarded
revised
Should we add constructors to structs?
added 1 character in body
Loading…
awarded
accepted
awarded
comment
Should we add constructors to structs?
@Doval that's not the question, I updatd the post. Steven: yes the constructors will only be just assigning default values.
revised
Should we add constructors to structs?
added 567 characters in body
Loading…
asked
Loading…
revised
Should I pass array or pointer?
added 41 characters in body
Loading…
comment
Should I pass array or pointer?
@Ramhound done, just updated the question.
revised
Should I pass array or pointer?
added 117 characters in body
Loading…
comment
Should I pass array or pointer?
since we are at it, I always thought a dry run of the same function can be used to return the required size but I have never seen this anywhere and don't know if I want to be the first :) For example getData(NULL, bfrSize) where the pointer is NULL, the function knows just to return the required size in bfrSize. Would that be too bad?
comment
Should I pass array or pointer?
@DocBrown but how does a client know how much buffer size should they allocate?
comment
Should I pass array or pointer?
What I am not sure about is the client is passing the buffer pointer and size, it doesn't seem to recognize how much buffer size the function actually needs which is defined by #define in header file. I guess first thing my function has to to do is check if the buffer size is at least as big as MAX_ITEMS_SIZE
comment
Should I pass array or pointer?
0 return means no error occurred but any other int indicates a particular error.
comment
Should I pass array or pointer?
I will only provide .lib and header file and I would expect it would work with at least windows compilers who knows from VC6 to VS2013 and gcc. I don't want to worry about that. Also even though I am using C++, I would like interface to be in C functions so they can be used more widely.
comment
Should I pass array or pointer?
I thought passing STL containers is not safe across different compilers when it comes to exposing them from a library?
comment
Should I pass array or pointer?
my return type is int where zero means success and non-zero indicates error. Sorry I missed that in my post, will update.
awarded