I don't use cuda, but from the advice handed down from IRC, it's recommended to install something like gcc into /opt into it's own package directory: /opt/gcc-<VERSION>.
You don't really need that <VERSION> part unless you want multiple versions of gcc in /opt. Anyways, what I would recommend is taking the SlackBuild (from Pat) and other files closest to the gcc version the program requires. Based on the thread you linked, it seems the person is using gcc-4.4.7.
Slackware 13.37 ships with gcc-4.5.2, but Slackware 13.1 ships with gcc-4.4.4. I can't guarantee gcc 4.4.7 will work with the 13.1 SlackBuild or even the 13.37 SlackBuild, but maybe you can give it a go. You never know until you try. Don't forget the other files that are also in the gcc.SlackBuild directory.
However, you should edit the SlackBuild to replace "usr" with something like "opt/gcc-$VERSION" or something. If all goes well, you have a different version of gcc installed into /opt/gcc-$VERSION/. So you'll see something like: "/opt/gcc-$VERSION/bin/gcc" or something.
Now you might be able to use:
Same export except with CXX instead of CC if cuda has C++ code in it.
If you don't want to do that export stuff (might forget after you're done running the script or something), you can symlink the /opt/gcc-$VERSION/bin/gcc to /usr/local/bin/gcc instead. In a default $PATH, /usr/local/bin is read before /usr/bin is so the symlinked gcc in /usr/local/bin would be used first before the newer gcc is. Although to be honest, you might forget to remove the symlink more than the export line since symlinks (in my opinion) are easier to forget. Either way, remember to remove the symlink or unset the environment variable you set with export, otherwise all of your programs will start compiling with this old gcc unless specifically told otherwise.
By the way, I said I don't use cuda and the advice I gave is what I could remember from IRC, so good luck (and I'm basically saying I gave you a fair warning ^.^ )!