Sunday, April 17, 2011

g++ command line options

  • -o : name the output file.
  • -Wall : all warnings.
  • -pedantic : follow strict ISO C++ rules.
  • -Weffc++ : follow Scott Myer's Effective C++ solutions.
More to come as a I experiment with them.

'NULL' was not declared in scope

(and cout, for that matter).

  • For NULL: use #include or
  • For cout: use the scope operator: std::cout or put 'using std::cout' at the top of the file.

Local SVN create and import troubles

I have this problem every time I try to create a new repository to use for version control.

First:

svnadmin has this thing about the 'create' feature using a path, not a URL, so the command (on Mac OS X) should be:

$ svnadmin create /Users/adam/vc/code

where /Users/adam/vc was already created via the

$ mkdir /Users/adam/vc

command.

Second:

Say you want to import a folder to your newly created repository. Per the help, it should be as simple as:

$ svn import file:///Users/adam/vc/code

where it assumes that the base folder is '.'. You can use -m to create the initial import message, but I have it bring up Vim as my editor.

Yay, it works, though I did have to fuddle with the invalid URL message a few times.

Great, let me check out my nice shiny new code so it's actually under version control:

$ svn co file://Users/adam/vc/code

Damn! What the hell is: "svn: Unable to open an ra_local session to URL" and "svn: Local URL 'file://Users/adam/vc/code' contains unsupported hostname"?

or for that matter this list of other errors as I play with the command?

svn: Local URL 'file://Users/adam/vc/code' contains unsupported hostname
svn: ':/Users/adam/vc/code' does not appear to be a URL
svn: Client error in parsing arguments

To say the least, it's been a big hassle. Here is what worked.

  1. Delete the folder that you may have already created in the repository folder (in my case 'code')
  2. Create the repository using this command: svnadmin create /Users/adam/vc/code (note: no 'file://' protocol).
  3. Create a folder that has the code you want to put under version control. Make sure the files you want in it are backed up, because you're going to delete it later. I named mine 'code' in this example.
  4. Import the folder (you need to be outside of the folder when you run this): svn import code file:///Users/adam/vc/code
  5. Remove the folder: rm -r code
  6. Checkout the folder from the repository: svn co file:///Users/adam/vc/code
There, that should it. All your files should scroll past you as it creates a new folder (in my case 'code') that is now under version control.

Why is this so painful? Granted, I didn't pay attention closely this time, but I had just done this on a Windows machine (under Cygwin) with no problems at all, so I assumed it'd be the same (of course, forgetting past experiences).