C/C Preprocessor


Deprecated: ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead in /project/www/devpit.org/mediawiki-1.23.8/includes/cache/MessageCache.php on line 731

Deprecated: ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead in /project/www/devpit.org/mediawiki-1.23.8/includes/cache/MessageCache.php on line 739

Deprecated: Creation of dynamic property PPDStack::$accum is deprecated in /project/www/devpit.org/mediawiki-1.23.8/includes/parser/Preprocessor_DOM.php on line 754

Deprecated: Constant E_STRICT is deprecated since 8.4, the error level was removed in /project/www/devpit.org/mediawiki-1.23.8/includes/GlobalFunctions.php on line 2409
From Devpit

Deprecated: ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead in /project/www/devpit.org/mediawiki-1.23.8/includes/cache/MessageCache.php on line 731

Deprecated: ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead in /project/www/devpit.org/mediawiki-1.23.8/includes/cache/MessageCache.php on line 739
Jump to:
Deprecated: ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead in /project/www/devpit.org/mediawiki-1.23.8/includes/cache/MessageCache.php on line 731

Deprecated: ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead in /project/www/devpit.org/mediawiki-1.23.8/includes/cache/MessageCache.php on line 739
navigation

Deprecated: ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead in /project/www/devpit.org/mediawiki-1.23.8/includes/cache/MessageCache.php on line 731

Deprecated: ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead in /project/www/devpit.org/mediawiki-1.23.8/includes/cache/MessageCache.php on line 739

Deprecated: Constant E_STRICT is deprecated since 8.4, the error level was removed in /project/www/devpit.org/mediawiki-1.23.8/includes/GlobalFunctions.php on line 2409

Deprecated: Constant E_STRICT is deprecated since 8.4, the error level was removed in /project/www/devpit.org/mediawiki-1.23.8/includes/GlobalFunctions.php on line 2409
,
Deprecated: ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead in /project/www/devpit.org/mediawiki-1.23.8/includes/cache/MessageCache.php on line 731

Deprecated: ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead in /project/www/devpit.org/mediawiki-1.23.8/includes/cache/MessageCache.php on line 739
search

Macros

  • The following C macro example is what GCC calls a 'statement expression'. It returns the value of the last expression in a statement block.
#define FOO(x) ({ \
  int foo = 1024;  \
  foo + x;         \
})
  • This expression will not expand out with the '{' '}' braces.
#define BAR(x) {  \
  bar = FOO(x);    \
}
  • For that you need:
#define BAT(x) do { \
  bat = FOO(x);      \
} while(0)

Function definitions

  • If you want to redefine function foo(bar) to foo_internal(bar) the following won't work:
#define foo (bar) foo_internal (bar)
  • You must use not have a space between foo and its parameter list:
#define foo(bar) foo_internal (bar)
  • This applies for normal macro function expansions in general. When invoking:
BAT(z);

with the following macro definition:

#define BAT (x) do { \
  bat = FOO(x);      \
} while(0)

It will expand as:

(x) { bat = FOO(x); }

Which is WRONG. You need:

#define BAT(x) do { \
  bat = FOO(x);      \
} while(0)

So that it expands as:

{ bat = FOO(z); }