Name: Anonymous 2011-11-24 12:59
Why must they feel the need to redefine all the primitives with different names?
#ifdef horror...
#ifdef _MSC_VER
// Windows
typedef unsigned long long u64;
#else
// Posix
#include <stdint.h>
typedef uint64_t u64;
//typedef unsigned long long u64;
#endif
typedef unsigned long long u64;typedef uint64_t u64;typedef unsigned long long uint64_t; for Windows?typedef structs constructs to the most extreme attempts on creating OO-driven abstractions and horrible "language extending" macros (GLib and the like), such a coder develops some particular paranoia with respect to some set of worries and issues, while completely disregarding other aspects of the (rather difficult, as it seems) art of programming. Unecessarily redeclaring (that is, hiding) identifiers through typedefs and sprinkling around tons of preprocessor directives (#ifdef being the least harmful of them) is just the small part of the problem.ls command, is what runs on the userspace of almost every modern Linux system nowadays. OpenSSL is what covers all of our security needs: http://www.peereboom.us/assl/assl/html/openssl.html. Microsoft code does not even respect the relevant standards. And things go on, as it seems, more crippled at each passing day; and the sole, the single reason of the problem is the presence of extremely uneducated people, which don't have the smallest grasp of the consequences of their acts, kludges and "well-thought decisions" in their Autotools-build-driven, #ifdef sprinkled, type-redefined, extension-dependent, completely undertested pieces of what they call "software".typedef bad with structs?const) pointer to it in order to achieve the same effect. It is also bad to directly return structures; a pointer to an output buffer is usually better. And while it is ok to stack-allocate int arrays in the stack, you'd rather avoid it with structures, since they can be much larger than an int, and may trash your stack area. With a structure, you expect it to be larger than you typical int variable, and you will refrain from doing a lot of things which you would do with scalar types.typedef struct is bad in a number of aspects. First, they disguise a structure as being an ordinary scalar type: it is hard to tell whether it is really a redefined scalar type (which is also bad), hard to tell whether it is addressable, whether they can be dereferenced (if pointers to structures), and so on. People may even attempt to do arithmetic with it, as if the type were really a scalar type (think about someone implementing a binary tree with your structure type as data, and using plain subtraction as a comparation criteria -- it won't work on aggregate types).
typedef struct my_struct {
// ...
} my_struct;typedef to structure types will do the same with unions. By simply looking at the type you can't differentiate a structure from a union, and the access to them is exactly the same (and they can even contain exactly the same members). While strong syntax is no excuse for lack of proper testing, in this particular case the syntax does help to better understand the code and avoid stupid mistakes.typedef in C is, in common practice, bad not only on structures, but in everything else. A typedef does not declare a new type: it's just an alias the compiler will happily ignore. Thus, it helps to do what should not be done in C: hiding information from the programmer. You can't properly printf() or scanf() typedef'fed variables, since you can't say if it is an int or long. You can't bitwise operate in it because it might be a float. You can't assign to it safely: it might be const. typedef is roughly meant to substitute #define, thus it limits itself to almost only what #define can achieve. It is meant to create opaque types due to standard-wide constraints and other implementation-specific issues, and even then, these types are very well documented.typedef together with unions (without the same sizing problems, but with the same syntactical unawareness problems), enumerations (namespace pollution) and types in general, when it is visibly not needed.
setbuf(stdout, NULL), what the fuck?!).struct every fucking time I use one.volatile won't issue memory barriers for you anyway.volatile was meant for memory-mapped IO and nothing else. If you want to do spinlocks, use assembly.
ooc.util.concurrent.atomic
volatile in particular, neither about memory fencing, neither about lack of availability of good quality information, neither about nothing in programming. Aside the attrition, there've been a couple of good observations; however, everything you've exposed in your example is a ridiculous, not to say pretentiously insightful, exposition of two-decade-aged processor architecturing, while being terribly off-topic at the same time, but that's easily explainable assuming the installation of such a severe malady. It's better to seek professional advice.typedef struct is a failproof way of detecting autism