Showing posts with label c++. Show all posts
Showing posts with label c++. Show all posts

Friday, September 2, 2011

Forcing Vim's syntax highlighting (for odd file extensions)

I often tend to keep backup copies of my C/C++ source files with odd extensions (i.e. something that does not end with CC or C). If these files are opened with Vim, they wouldn't be recognized as they should, which means my CTAGS extension and colored syntax highlighting would both refrain to work. The quick solution to this problem is to tell Vim explicitly about the file type. Here is how one can do it:
:setfiletype c
More information on it, as always:
:help setfiletype

Monday, March 10, 2008

Big decimal integer constant warning


warning: this decimal constant is unsigned only in ISO C90

if there is no suffix added to the constant:

C90 compilers will follow the following order to read that constant:
  • int
  • long int
  • unsigned long int
while C99 compilers the following order:
  • signed int
  • signed long
  • signed long long
solution:
  1. consult compiler (gcc) documentation
  2. add proper suffix (ex. UL)
code snippet:


if((u64)s[i-1]>4294967295UL) {
s[i-1]=0;
}

Tuesday, March 4, 2008

All C/C++ manpages

apt-get install manpages
apt-get install manpages-dev
apt-get install manpages-posix-dev