Consistent preprocessor include guards for all src/lib/ headers (58 headers)BRL-CAD
Status: ClosedTime to complete: 72 hrs Mentors: SeanTags: code cleanup, header, consistency, C, code, simple, perl, python, scripting

BRL-CAD source code currently has over 450 C header (include) files. Header files usually include a preprocessor block that ensures the header is only included once. It usually looks something like this:

#ifndef THIS_HEADER
#define THIS_HEADER
... file contents ...

#endif /* THIS_HEADER */

This tasks basically involves editing that THIS_HEADER string for the src/lib* subdirectory headers so that they're using a consistent header guard naming convention. Some of our files use a convention like __FILE_H__ while others use FILE_H or FILE_H__ or others still using some other convention.

Your job is to make them all the same, based on the file name, for some of our headers. Our convention should be {SUBPATH_}FILENAME_H where SUBPATH indicates the subdirectory where the header resides minus the first directory; and FILENAME_H is the name of the file with punctuation and spaces converted to underscores.

Some examples:

  • include/bu.h becomes just BU_H
  • src/libbu/anim.h becomes LIBBU_ANIM_H
  • src/conv/iges/iges.h becomes CONV_IGES_IGES_H

Code:

  • src/lib* (e.g., src/libbu, src/librt, src/librt/primitives/nmg, etc)
References:
  • http://brlcad.org/wiki/Compiling

Suggest using the VM if you're not on Linux, but this command will locate all of the header files for you from the top of a source tree checkout:

find . \( -not -regex '.*src/other.*' -not -regex '.*svn.*' -not -regex '.*cmake.*' \) -name \*.h | grep 'src/lib'

This is a lot of edits, but they are very simple edits. You don't even really need to understand C to do this task, but it might help you go a little faster. You're welcome to write a script or not.

You only need to be able to first compile BRL-CAD successfully so you can recompile during/after your edits and know whether you changed anything wrong.

Obtain our trunk sources from a Subversion checkout or VM from Sourceforge. Submit a patch file of all your changes: svn diff my_patch.diff


Uploaded Work
File name/URLFile sizeDate submitted
src_lib_headers.tar.gz5.4 KBDecember 18 2013 14:58 UTC
src_lib_headers_rev2.diff27.2 KBDecember 18 2013 21:57 UTC
Comments
Peter Amidonon December 18 2013 05:23 UTCTask Claimed

I would like to work on this task.

Mandeep Kaur on December 18 2013 05:34 UTCTask Assigned

This task has been assigned to Andromeda Galaxy. You have 72 hours to complete this task, good luck!

Peter Amidonon December 18 2013 15:00 UTCReady for review

The work on this task is ready to be reviewed.

Sean on December 18 2013 21:24 UTCthe skipped ones

Andromeda,


This looks great except for the ones that you skipped.  The three qray files should have header guards per the naming convention.  The other libfb cursor files could have guards added too, but they are unimportant (one is unused, I'm deleting it).


I may have said it already, but please do read over our HACKING file, particularly the section on contributor responsibilities as it's relevant for your future tasks.  We can discuss on IRC in more detail.

Sean on December 18 2013 21:24 UTCTask Needs More Work

One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.

Peter Amidonon December 18 2013 21:57 UTCReady for review

The work on this task is ready to be reviewed.

Sean on December 18 2013 23:51 UTCTask Closed

Congratulations, this task has been completed successfully.

Sean on December 18 2013 23:56 UTClooks perfect

On quick review, this looks good now.  Assuming you've tested compilation and all works, go ahead and commit your work.  Welcome to your new BRL-CAD contributor status.


Please read all of HACKING and let me know if you don't understand or agree with anything in our contributor responsibilities section.