2011/11/17

VIM with tags

Using vim coding program for a long time. It's a very good tool "ctags" to work with vim when coding.

Create tags

#ctags -R *

Naming tags

#ctags -R * -f tagName

In vim, using below command to setting PATH of tags:

:set tags=./tags,../tags

or

:set tags=tags; Add ; can recursive search tags from parent folder.

2011/11/10

[C/C++ basic] Preprocessing #if defined(SHAWN)

It's lot of usage same as #ifdef Like #if defined(...) When using #if defined(...) we can used logic AND/OR for preprocessing.

Sample 1:

#ifdef ABC
// do something
#elif DEF
// do something
#else
// do something else
#endif

Sample 1 above can be simply recoding as:

#if defined(ABC) || defined(DEF)
//do something
#else
// do something else
#endif

2011/11/04

[C/C++ basic] Preprocessing #ifdef, #elif, #else

Today I using C/C++ preprocessor to compile my code, But I have a little confuse about "is #elif can work correctly with #ifdef"?
#ifdef TEST_IFDEF
	printf("Test #ifdef");
#elif TEST_ELIF
	printf("Test #elif");
#else
	printf("Test #else");
#endif
And after my trying. It's work well :D