Posts Tagged ‘C++’

Applescript to add inclusion guards to C++ Header files in Xcode

April 26th, 2009 No comments

I got tired of manually adding them, so here’s a little script…

set list_lib to load script alias “Path:To:List Utilities.scpt”

tell application “Xcode”

Get file name of front-most document (via window)

set header_file_path to associated file name of window 1


Go back and get the source file using the name

set header_file to first source document whose path is header_file_path

Turn the file into a list of lines to
— find the insertion point for the inclusion guard

set lines_of_header to paragraphs of text of header_file

Create the inclusion guard based on the file name

set inclusion_guard_token to first word of (get name of header_file) 

set guard_start to “\n#ifndef “ & inclusion_guard_token 
& “\n” & “#define “ & inclusion_guard_token & “\n”


Insert the start of the guard

set lines_of_header to list_lib‘s list_insert(lines_of_header, guard_start, 9)

Insert the end of the guard

set end of lines_of_header to “\n\n#endif”

Set the revised contents of the file

set text of header_file to (lines_of_header as text)

end tell

List Utilities.scpt (code from AppleScript: The Definitive Guide, 2nd Edition:

on find_in_list(what, L)

repeat with i from 1 to count L

if item i of L is what then

return (a reference to item i of L)

end if

end repeat


end find_in_list

on list_insert(L, what, ix)

if ix = 1 then

return {what} & L


return {item 1 of L} & list_insert(rest of L, what, ix - 1)

end if

end list_insert

Categories: Mac, Programming Tags: , ,

Hippomocks 2.0 on Mac OS X

April 22nd, 2009 No comments

I’m exploring Hippomocks, a C++ mock library.


The library supplies a test suite for compilers not known to be supported.  GCC is listed, but I think Apple’s version is a little different than standard GCC, so I’ll run that.  Pretty easy in Terminal:

  1. “cd /path/to/Hippoocks/HippoMocksTest/”
  2. “make test” (there’s also a test0x, but it requires >= GCC 4.3, which is confirmed when my Mac doesn’t recognize “-std=c++0x”)

And… errors :(  But easy ones to fix…

cc1plus: warnings being treated as errors

../HippoMocks/hippomocks.h:139: warning: ‘class func_index’ has virtual functions but non-virtual destructor

is_virtual.cpp:4: warning: ‘class IL’ has virtual functions but non-virtual destructor

test_class_mock.cpp:24: warning: ‘class IG’ has virtual functions but non-virtual destructor
n.b. the above errors were over several compiles, but I showed them together for brevity.
Picking up where we left off… “make test” now succeeds, and ./test reports:
The final step, per the installation instructions, is to copy the single header file, hippomocks.h, into a system directory.  I’m putting it in /usr/local/include.
That’s it!  The library is ready for use in all my C++ projects.  All I have to do is #include <hippomocks.h> and go to town.
Categories: Mac, Programming Tags: , , , , ,

Wt Web Toolkit on shared litespeed host

April 13th, 2009 No comments

As excited as I was about wt, I was equally worried that I would not be able to get wt set up correctly since I use a shared host.  

First, shout out to for all the support.  They use litespeed, for which there seems to be no setup instructions online.  

We finally got it going by:

  1. adding the Wt app as a FastCGI “External application” in litespeed’s admin interface
  2. then /path/to/relevent/folder/under/webroot/.htaccess: AddType application/x-httpd-[insert name of ext app here] [insert file extension]

I would prefer to use a SetHandler instead of the dummy file required by AddType, but I’m really splitting hairs now – it’s working, so I’ll put it on my list of things I’m not doing now and start coding already!

UPDATE: The above approach is unworkable because:

  1. My shared host uses Apache configurations (not the Litespeed admin console) to set up virtual hosts
  2. In it’s current version (4.0.1), Litespeed does not support Apache configurations for FastCGI (Litespeed support said that they will be implemented in the next subversion.

What this means is that my app would be started by the Litespeed web server under its user and group IDs, not suExeced like PHP or CGI apps.  Because I do not own the process, every time there is a problem with it (or I update the binary), I would have to contact customer support and have them manually kill the processes.  Obviously, this would not work.

However, it doesn’t matter anyway because…

After several emails with Koen from Wt, I found out that, for a public site, they recommend using the built-in wthttp server with the public web server (e.g. Aapche) as a reverse proxy.  I can not do for the same two reasons – my hosts method of virtual hosting and the limits to Apache configurations in Litespeed (in this proxy configs)

So, I’m switching to one of my host’s servers with Apache, which can easily be configured as a reverse proxy with wthttp (the user will communicate with Apache, which will forward all requests to wthttp, without the user ever knowing that anything is going on behind the scenes).

Categories: Web Development Tags: , , ,

wt Web App C++ Library

April 7th, 2009 No comments

I love the idea of the wt toolkit: create an application, just like any desktop app.  Then, use wt for the “GUI” which hides all the web technologies and automatically handles the communication between the web server and my app.  wt will determine the best way to display the UI compatibly with the user’s browser.

OMG!  I can use my existing C++ skills to create awesome web apps without wasting time learning the panoply of ever-evolving web technologies – AJAX, HTML, Javascript – all taken care of by people who know them far better than me.

Categories: Programming, Web Development Tags: , ,

Building Boost Libraries for Mac ppc & x86

April 7th, 2009 No comments

By default, Boost builds libraries for your native architecture only.  I’m sure there is a better way, but an easy way I found without manually using bjam is adding “architecture=combined” to the makefile that configure generates.  E.g:

@$(BJAM) $(BJAM_CONFIG) –user-config=user-config.jam –prefix=$(prefix) –exec-prefix=$(exec_prefix) –libdir=$(libdir) –includedir=$(includedir) architecture=combined $(LIBS) install || echo “Not all Boost libraries built properly.”

Categories: Mac, Programming Tags: ,

C++ XML Parser Library wrapper Part 2: expatmm

April 1st, 2009 No comments

After my expatpp adventure, I took a sharp turn and switched to expatmm.  It too is a C++ wrapper to expat, but it seems more up-to-date (working with the latest version of the expat library) and has replaced expatpp on the expat 3rd party links.

It works great out of the box on Mac OS X 10.5.6.  It built and installed (using configure and make) with only one small problem – I had to change ExpatMM-version.cpp to hardwire the version # in.  Once that change was made, I included and linked to the lib from Xcode with no problem.

Categories: Programming Tags: , , , ,

Linking to shared libraries in non-standard locations in Linux

March 12th, 2009 No comments

I wrote a CGI app in C++ which compiled and linked with no problem.  When I ran it, thud: 

error while loading shared libraries… can not open shared object file… no such file or directory

The problem is that programs don’t hard-code paths to shared libs.  This works great most of the time because the app simply searches the standard lib paths and find it.  However, if the shared lib is elsewhere, game over – runtime link error.

Since it was only this program that needed to link to the library, I used a linker option that adds a directory to the runtime library search path: the -rpath flag.  Since I was using g++ through a makefile, I passed the flag to the linker via -Wl, which – you guessed it – passed flags to the linker!  The full LDFLAGS were: -L/path/to/shared/lib -l[libname] -Wl,-rpath,/path/to/shared/lib.  The commas are a little weird and through me off at first, but they are correct.  You can read about the syntax here (for -Wl) and here (for -rpath) and here (for the combination).

Exactly what I wanted: the program can find the library at runtime in its non-standard location!

Categories: Linux, Programming Tags: , ,

windows 7 product key

windows 7 product key

windows 7 key generator

windows 7 key generator

free winrar download

free winrar download

winzip activation code

winzip activation code

free winrar

free winrar

winzip free download

winzip free download

winrar free download

winrar free download

winrar download free

winrar download free

winzip free download full version

winzip free download full version

windows 7 activation crack

windows7 activation crack

windows 7 crack

windows 7 crack

free winzip

free winzip