Skip to content
Wu Jie edited this page Mar 30, 2014 · 2 revisions

Declare/Define a macro

All macros should define with upper-case character.

Special Case:

  1. Expose to user, define it by adding prefix "EX_".

    #define EX_FOOBAR 1

Declare/Define a variable

All local variable should start with lower-case character.

Special Case:

  1. use prefix __ define a static variable in .c file.

    // file name: test.c
    static int __counter = 0;
  2. use prefix _ declare a parameter in a function.

    void foobar ( int _count ) {
        ...
    }

Declare/Define a structure

  1. Always add ex_ prefix and _t suffix for structure exposed to user.

    typedef struct ex_foobar_t {
    } ex_foobar_t;

Declare/Define a funciton

  1. Always add extern keyword when declare a global function in a header file.

    extern void foobar (int);
  2. use prefix __ define a static function in .c file.

    static void __foobar () {
        ...
    }
  3. Always add ex_ prefix for function write in exsdk exposed to user.

    extern void ex_foobar (int);

Clone this wiki locally