3
votes
3answers
155 views

Organization of DLL linked functions

This is a code organization question. I got my basic code working but when I expand it, it will be terrible. I have a DLL which I don't have a .lib for. Therefore I have to use the whole ...
3
votes
2answers
237 views

using unsigned integers in c, c++

I have a very simple question that baffles me for a long time. I am dealing with networks and databases so a lot of data I am dealing with are 32-bit and 64-bit counters (unsigned), 32-bit and 64-bit ...
8
votes
6answers
897 views

Should my team use some common well-regarded coding standard as a basis for its own?

The R&D team I'm in has decided to adopt a coding standard. We have only recently formed, and have too little code and common coding time of our own to base our standards/conventions document on ...
0
votes
2answers
335 views

What is the exact syntax of inline?

CASE 1 (Definition and declaration in same source file) Suppose both my prototype and definition of global function is in .cpp file. Where should I write inline keyword to make compiler know? In ...
2
votes
1answer
303 views

Maintaining code-style conventions for large projects [closed]

For a while I've been maintaining an ad-hoc script to check code style against our project's guidelines. I'm aware of AStyle/Uncrustify and have used them, but they are best for once-off code-style ...
3
votes
3answers
332 views

Blank lines in C

I'm working through K&R and I notice that their code is extremely tightly spaced. I haven't developed C since at University, but professionally most source from other languages I've worked in has ...
4
votes
6answers
2k views

sizeof style: sizeof(type) or sizeof variable?

I've seen two styles of using sizeof for memory-related operations (such as in memset or malloc): sizeof(type), and sizeof variable or sizeof(variable) Which one would you prefer, or would you use ...
6
votes
3answers
658 views

Reason for placing function type and method name on different lines in C

I just started at a company and one of the style comments at my first code review was that the return type and method name should be on different lines. For example, this void foo() { } should be ...
1
vote
4answers
2k views

Is using `continue`, `break` in non-`switch` loops and `?:` bad practice? [duplicate]

Back in college I've been told that using break; and continue; outside switch statements (e.g. to escape for or while loops) is wrong, bad practice and bad habits at the same time because it only ...
0
votes
2answers
261 views

Need some advice and feedback on my code's design

I am looking for feedback on the design of my program. I have a shell script call function.sh that defines a lot of helper functions. My intent is to use those bash functions defined in functions.sh ...
2
votes
4answers
1k views

Should I use C style in C++?

As I've been developing my position on how software should be developed at the company I work for, I've come to a certain conclusion that I'm not entirely sure of. It seems to me that if you are ...
7
votes
9answers
1k views

Is it any good to use binary arithmetic in a C++ code like “C style”?

I like the fact that the C language lets you use binary arithmetic in an explicit way in your code, sometimes the use of the binary arithmetic can also give you a little edge in terms of performance; ...
1
vote
4answers
552 views

Indenting labels in C

I noticed that in the Vim automatically indents labels in a rather unintuitive way (IMHO). int main(void) { goto end; end: return 0 } Are there any style guidelines for labels? For the ...
-1
votes
2answers
209 views

How should I group these variables?

I have a shape that will be defined by: char s_type; char color; double height; double width; These variables are scanned in from a request string sent to my server and passed into my printing ...
6
votes
8answers
417 views

What is the possible disadvantage of putting declarations in inner blocks, instead of at beginning of function?

At the place where I work, there are explicit guidelines for placement of declarations of variables. According to that, it is required to put them at the global level and / or at the beginning of ...
3
votes
3answers
306 views

Do simple accessors and mutators benefit from commented block headers?

Short Question Is it necessary to add the function header comments for simple accessors and mutators? Example u8 OBJ_get_state_x(void) {return obj.state_x;} void OBJ_set_state_x(u8 x) ...
45
votes
16answers
3k views

Strictness in programming methods among Stack Overflow users [closed]

I've been a member of Stack Overflow for a couple of weeks now and have answered questions and read others answers, mostly in C/C++. True, I have learned about some things. For example, undefined ...
-1
votes
2answers
1k views

[C] Address of array elements [on hold]

What is the most readable way of using address of an array element? I usually see &array[n] but I personally think array+n looks cleaner and more readable. What do other C coders prefer?
4
votes
7answers
405 views

Returning from a long function on the first false condition

I have a long(ish) function of the following pattern: bool func(some_type_t *p1, another_t *p2) { bool a = false, b = false, c = false, etc = false; a = (some_long && expression ...
4
votes
8answers
493 views

Programming style: Reoccuring error checks

Hey, I have a question about programming style, because in my current code I am using a bigger function which calls some smaller functions and all of these need to be error-checked. So something like ...
11
votes
5answers
1k views

If you favor “T *var”, do you ever write “T*”? [duplicate]

Possible Duplicate: int* i; or int *i; or int * i; Thinking about where we place our asterisks; how do those that prefer to keep the "pointerness" away from the type and with the identifier ...
16
votes
12answers
5k views

int* i; or int *i; or int * i; [closed]

What is your favorite method to declare a pointer? int* i; or int *i; or int * i; or int*i; Please explain why. see also: http://www.stroustrup.com/bs_faq2.html#whitespace