Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- C99



  C Preprocessor Hell

Lisp programmers should stop reading right now because they'll likely suffer severe injury of the jaw muscles as they laugh themselves silly at how hard it is to do some things in C. The C language has a pre-processor (typically called cpp) that is both infuriating and powerful. How powerful is usually best described as 'just too little' and it has happened more than once that I found myself almost - but not quite - able to do what I wanted to do. The frustration can run very deep at ti...

   C,Preprocessor,Lisp,Hell     2012-01-19 10:22:31

  Why would I learn C++11, having known C and C++?

I am a programmer in C and C++, although I don't stick to either language and write a mixture of the two. Sometimes having code in classes, possibly with operator overloading, or templates and the oh so great STL is obviously a better way. Sometimes use of a simple C function pointer is much much more readable and clear. So I find beauty and practicality in both languages. I don't want to get into the discussion of "If you mix them and compile with a C++ compiler, it's not a mix ...

   C++11,New feature,Study     2012-03-16 08:44:38

  How Many C Programs Are There?

If I choose a size S, can you tell me how many valid C programs exist that are no larger than that size? I’m actually interested in the answer — it’ll help me make a point in a paper I’m writing. Shockingly, the Internet (or at least, the part of it that I looked at based on a few searches) does not provide a good answer. Let’s start with a few premises: Since it would be exceedingly difficult to construct the exact answer, we’re looking for a respe...

   C Progra,Number,Statistic,Calculation     2012-02-22 05:18:32

  The ugliest C feature:

<tgmath.h> is a header provided by the standard C library, introduced in C99 to allow easier porting of Fortran numerical software to C. Fortran, unlike C, provides “intrinsic functions”, which are a part of the language and behave more like operators. While ordinary (“external”) functions behave similarly to C functions with respect to types (the types of arguments and parameters must match and the restult type is fixed), intrinsic functions accept arguments of...

   C,,Fortran,Intrinsic functions,C99,Ugly     2011-12-26 08:33:27

  Preprocessor magic:Default Arguments in C

This post is for programmers who like C or for one reason or another can't use anything else but C in one of their projects. The advantages of having default arguments is not something that needs convincing. It's just very nice and convenient to have them. C++ offers the ability to define them but C under the C99 standard has no way to allow it. In this post I will detail two ways I know of implementing default arguments in C. If a reader happens to know additional ways please share in ...

   C,Preprocessor,Default arguments     2012-02-19 06:17:04

  Faster than C

Judging the performance of programming languages, usually C is called the leader, though Fortran is often faster. New programming languages commonly use C as their reference and they are really proud to be only so much slower than C. Few language designer try to beat C. What does it take for a language to be faster than C? Better Aliasing Information Aliasing describes the fact that two references might point to the same memory location. For example, consider the canonical memory copy: void...

   C,Performance,Speed,Fortran,Criteria     2012-03-25 09:12:23

  Error handling in GoLang

Error handling is one of the must talked topics for any programming language. The program would be more reliable and stable if errors are handled properly and timely. Each programming language has its own way to handle error, this applies to GoLang as well. This post will discuss more about GoLang's error handling mechanism. Error handling Before talking more about GoLang's error handling, we can see how different programming languages are handling errors. C's error check The most direct way of ...

   GOLANG,ERROR HANDLING,FLUENT INTERFACE     2021-03-06 21:36:08

  Understanding lvalues and rvalues in C and C++

The terms lvalue and rvalue are not something one runs into often in C/C++ programming, but when one does, it’s usually not immediately clear what they mean. The most common place to run into these terms are in compiler error & warning messages. For example, compiling the following with gcc: int foo() {return 2;} int main() { foo() = 2; return 0; } You get: test.c: In function 'main': test.c:8:5: error: lvalue required as left operand of assignment True, this code ...

   lvalue,rvalue,C++,locator value,elaboration     2011-12-15 07:51:38

  C Macro Tips and Tricks

Preprocessor vs Compiler To properly understand C macros, you must understand how a C program is compiled. In particular, you must understand the different things that happen in the preprocessor and in the compiler. The preprocessor runs first, as the name implies. It performs some simple textual manipulations, such as: Stripping comments. Resolving #include directives and replacing them with the contents of the included file. Evaluating #if and #ifdef directives. Evaluating #defin...

   C,Macro,Preprocessor,Trick     2012-05-01 06:49:05

  The trap of the performance sweet spot

This post is about JavaScript performance but I would like to start it by telling a story that might seem unrelated to JS. Please bear with me if you don’t like C.A story of a C programmer writing JavaScriptMr. C. is a C programmer as you can probably guess from his name. Today he was asked by his boss to write a very simple function: given an array of numbered 2d points calculate vector sum of all even numbered points... He opens his favorite text editor and quickly types somet...

   C,JavaScript,Sweet spot,Memory,Low level,Trap     2011-11-06 14:45:01