Google
 

8/23/07

C++ Naming Standards (DRAFT)

It is helpful to use the name convention consistently when you write the program. In this site I got the following "standard". I think it is very useful so I copy it here.


The following standards are intended to provide guidance for development of names defined within C++ programs developed by the IHFS project. The standards are derived from the C++ Coding Standards developed by the European Laboratory for Particle Physics (CERN) which can be found at http://axaonl.cern.ch:8000/a_doc$www/ONLINE/CXX_CODING_STANDARDS.HTML#names

All Upper Case Abbreviations

All upper case abbreviations are acceptable when the abbreviation is well known and in common use. e.g. - RFC

Class Names

Use upper case letters as word separators, lower case for the rest of a word First character in a name is upper case No underscores '_'

Class Library Names

Until Namespaces are widely implemented in C++, libraries in danger of conflicting with other libraries should choose some sort of unique prefix to avoid name conflicts. It's common for a prefix to be two characters, but a longer length is acceptable.

Method Names

Use the same rule as for class names.

Class Attribute Names

Use lower case attribute names Separate keywords with underscores '_'

Method Argument Names

The first character should be lower case. All words beginning after the first letter should be upper case as with class names.

Variable Names on the Stack

use all lower case letters use underscore '_' as the word separator.

Pointer Variables

Pointers should be prefixed by a 'ptr' Place the * close to the pointer type not the variable name

Reference Variables

References should be prefixed with 'ref'

Global Variables

Global variables should be prefixed with 'glo'.

Static Variables

Static variables should be prefixed with 'sta'

Type Names

When possible, make a typedef for types based on builtin types. Typedef names should use the same naming policy as for a class with the word Type appended.

C Function Names

In a C++ project there should be very few C functions. For C functions use the GNU convention of all lower case letters with '_' as the word delimiter.

Enum Names

Labels All Upper Case with '_' Word Separators

8/20/07

Install Chinese fonts on ubuntu (feisty).

1. Need to use "System Settings", then select "Regional and Language" to choose the language.
2. sudo dpkg-reconfigure locales

8/12/07

firefox crashes.

It always crashes when I logged into my gmail account. It turned out that it is due to the plugin "flashplayer". When I entered the home directory,
cd ./mozilla
cd firefox
cd plugins
I just deleted the libflash*.o
Now firefox works.

Install Qt4.3

I had the following error:

In file included from kernel/qpsprinter.cpp:97:
kernel/qt_x11.h:65:22: X11/Xlib.h: No such file or
directory
kernel/qt_x11.h:71:23: X11/Xutil.h: No such file or
directory
kernel/qt_x11.h:72:21: X11/Xos.h: No such file or
directory
kernel/qt_x11.h:73:23: X11/Xatom.h: No such file or
directory
kernel/qt_x11.h:84:34: X11/extensions/shape.h: No such
file or directory

Solved by following:
installed "xlibs-dev" package

8/6/07

ubuntu boot up message.

I could not see any message when the computer starts up. The solution is to press: Ctrl+Alt+F1

8/4/07

fstab and User permission.

User Permissions

To give read/write permission to everyone, add this phrase to the options for the file_system in your file /etc/fstab:

"gid=users,umask=000"

You need to have root access to edit that file. The whole line will look something like this:

/dev/hdxy   /mnt/hdxy  file_system  noatime,user,exec,dev,suid,gid=users,umask=000  0  0
  • x will be a letter starting with a, then b,c,....
  • y will be a number starting with 1, then 2,3,....

File types:

  • Linux file systems:
    • ext2, ext3, jfs, reiserfs, reiser4, xfs, swap.
  • Windows:
    • vfat = FAT 32, FAT 16
    • ntfs= NTFS

Additional Options: (From wiki.linuxquestions.org):

  • sync/async - All I/O to the file system should be done (a)synchronously.
  • auto - The filesystem can be mounted automatically (at bootup, or when mount is passed the -a option). This is really unnecessary as this is the default action of mount -a anyway.
  • noauto - The filesystem will NOT be automatically mounted at startup, or when mount passed -a. You must explicitly mount the filesystem.
  • dev/nodev - Permit any user to mount the filesystem. This automatically implies noexec
  • exec / noexec - Permit/Prevent the execution of binaries from the filesystem.
  • suid/nosuid - Permit/Block the operation of suid, and sgid bits.
  • ro - Mount read-only.
  • rw - Mount read-write.
  • user - Permit any user to mount the filesystem. This automatically implies noexec, nosuid,nodev unless overridden.
  • nouser - Only permit root to mount the filesystem. This is also a default setting.
  • defaults - Use default settings. Equivalent to rw, suid, dev, exec, auto, nouser, async.
  • _netdev - this is a network device, mount it after bringing up the network. Only valid with fstype nfs.

The "umask" is "user mask" and it sets the permission bits for permission that is not allowed if you wish to change the default.

VFAT/NTFS:

Syntax is "odd" at first.

  • To set a permissions of 777, umask=000
  • to set permissions of 700, umask=077
    • o= Sets owner. Syntax: must use owned by USER ID # not name.
    • g= sets group ownership of mount point. Again syntax is by GROUP ID # not name.

022 means everything is allowed for root, writing/executing are allowed for group and world.


Following is my /etc/fstab file.

# /etc/fstab: static file system information.
#
#
proc /proc proc defaults 0 0
/dev/sda6 / ext3 defaults,errors=remount-ro 0 1
/dev/sdb1 /backup ext3 rw,uid=1000,gid=1000 0 2
/dev/sda5 /data vfat rw,noatime,uid=1000,gid=1000,user 0 0
/dev/sda12 /home ext3 defaults 0 2
/dev/sda10 /tmp ext3 defaults 0 2
/dev/sda7 /usr ext3 defaults 0 2
/dev/sda8 /usr/local ext3 defaults 0 2
/dev/sda9 /var ext3 defaults 0 2
#/dev/sdb2 /win vfat rw,user,auto,umask=000 0 0
/dev/sdb2 /win vfat rw,user,auto,uid=1000,gid=1000 0 0
/dev/sda1 /windows vfat defaults 0 0
/dev/sda11 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0