#
# Environment setup script for Houdini.
#
# To use this script you should "cd" to the hfs directory where this
# script is located and "source" it into your bash shell or from your
# .profile script.
#
# Alternatively you may copy this script, remove the first if
# statement and change the setting of the "HFS" variable to be
# the location of your installed Houdini hfs directory.
#
# Note that this script modifies your search path by inserting the
# Houdini bin directory at the beginning. It may also sets the environment
# variable LD_LIBRARY_PATH which is used to search for runtime libraries.
#
# To run the script in quiet mode, specify the "-q" option on the
# command line.
#
if [ ! -d houdini -o ! -d dsolib -o ! -d bin ]
echo "You must cd to the Houdini installation directory before"
echo "sourcing this script. This allows the script to determine"
echo "the installed location."
else
set -gx HFS "$PWD"
#
# The following are some handy shortcuts:
#
set -gx H "$HFS"
set -gx HB "$H/bin"
set -gx HDSO "$H/dsolib"
set -gx HH "$H/houdini"
set -gx HHC "$HH/config"
set -gx HHP "$HH/python3.11libs"
set -gx HT "$H/toolkit"
set -gx HSB "$HH/sbin"
#
# The following is used as the generic /tmp path. This is also
# set on Windows to the temporary directory, so can be used for
# system independent .hip files.
#
set -gx TEMP /tmp
#
# Look for java.
#
if [ "$JAVA_HOME" = "" ]
# Check in PATH first
set -l d (which java 2>&1)
if [ "$status" = "0" ]
set -gx JAVA_HOME (echo "$d" | sed 's/\/bin.*//g')
else
for dir in /usr/local /usr/local/java2 /usr/local/java /opt /usr /usr/java2 /usr/java
if [ -d "$dir" ]
set -l d $(find "$dir" -maxdepth 3 -path "*/bin/java" -printf "%h\n" 2> /dev/null | head -1 | sed 's/\/bin//')
if [ "$d" ]
set -gx JAVA_HOME "$d"
break
end
end
end
end
end
# We only need to set LD_LIBRARY_PATH if the environment also uses it. This
# makes sure HDSO is always searched first. Houdini binaries are built with
# DT_RUNPATH set so it only gets used after LD_LIBRARY_PATH.
if [ "$LD_LIBRARY_PATH" != "" ]
set -gx LD_LIBRARY_PATH "$HDSO:$LD_LIBRARY_PATH"
end
# If the java binary exists but cannot be found, then add JAVA_HOME
# to PATH. Otherwise, only add HB and HSB to PATH.
set -l java_path (which java 2>&1)
set -l which_java $status
if [ "$JAVA_HOME" = "" -o "$which_java" = "0" ]
set -gx PATH "$HB:$HSB:$PATH"
else
set -gx PATH "$HB:$HSB:$JAVA_HOME/bin:$PATH"
end
set -gx HOUDINI_MAJOR_RELEASE 20
set -gx HOUDINI_MINOR_RELEASE 5
set -gx HOUDINI_BUILD_VERSION 304
set -gx HOUDINI_VERSION "$HOUDINI_MAJOR_RELEASE.$HOUDINI_MINOR_RELEASE.$HOUDINI_BUILD_VERSION"
# Build machine related stuff
set -gx HOUDINI_BUILD_KERNEL "4.18.0-513.18.1.el8_9.x86_64"
set -gx HOUDINI_BUILD_PLATFORM "Red Hat Enterprise Linux release 8.9 (Ootpa)"
set -gx HOUDINI_BUILD_COMPILER "11.2.1"
# This only applies for linux systems
set -gx HOUDINI_BUILD_LIBC "glibc 2.28"
if [ $statusprompt ]
if [ "$1" != "-q" ]
echo "The Houdini $HOUDINI_VERSION environment has been initialized."
end
end
#
# These environment variables are no longer supported.
#
set -gx HIH "$HOME/houdini$HOUDINI_MAJOR_RELEASE.$HOUDINI_MINOR_RELEASE"
set -gx HIS "$HH"
end
Me, myself and I – A short biography
Prefix
I am about to turn 51, and recently been diagnosed with probable dysthymia. That have made me think about myself and my life, and made me write this short biography about myself.Childhood
I was born in January of 1973 to what can only be described as two working class parents. My dad didn’t stick around for a long time (but we still have a good relationship), so I was left to be raised by a working single mom. As she was still in her early twenties, she still went out to party and dance with friends, but she would then take me to my maternal grandmother for me to sleep over. We would go there most weekends anyway, so I spent quite a lot of time there. My uncle lived there as well, and we started to take long walks in the forests and fields around the area. Most of it was owned by the military and they had a large compound just a little bit away. So I often found used shell casings or cartridges which I for some reason collected and brought with me to my grandmothers house where they were stored in a drawer in a cabinet. I had another uncle living close by, and he had a son in my own age and I used to go there to play with him quite often, or he would come to us. I was rather young but I still was allowed to walk the kilometer or so to their house alone. I also often got a little money by my grandmother and would walk alone to the kiosk a couple of hundred meters away, to buy candy. Salty and sour was my favorites, and still are. The apartment we lived in was a simple two-bedroom apartment, and I got the big room. It was in an area with a lot of other families, with plenty of playgrounds and children around. You could easily go around the whole complex without crossing any roads, so pretty safe as well. Our bedrooms faced a forest which stretched for quite a bit (for a small child) and it was great for playing around in. Unfortunately there was one kid in my own age that decided that I could easily be teased, and unfortunately that was only the start of my missery. The first couple of years my daycare was a lady who had an apartment close to moms work, so me and a few other children spent our days there. After a while I got into a “proper” kindergarten where I stayed until I was six. Then I went to something called “lekis” (approximately “playing” in English) to prepare for school. While I have memories from kindergarten and school, “lekis” was rather uneventful and I don’t really remember much of it. It was at kindergarten that my life-long problems started. I was what you can only call stubborn, perhaps even obstinate. If I didn’t want to do something, I didn’t do it. Unfortunately that also was true for food and eating, and the teachers at kindergarten just couldn’t handle it in a good way. I could often be left alone at the table at lunch, while the other children went away to play, because the teachers needed me to eat my food and wouldn’t let me go. This made me want to each what they told me even less. And it still sticks with me to this day: I am a very picky eater, not even wanting to try new things (well, it happens, but very seldom, and only for very specific types of food).School
In the autumn of 1980, when I was seven, I started first class in school. Here the problems from kindergarten was pretty much dwarfed by a couple of teaches who just could not handle a child with above average intelligence. You see, when I started school I could already read well. I might even have known a little math, and even if I didn’t I picked it up extremely easy. I learned to read already when I was around 3-4 years old, and sometimes brought books with me to kindergarten to read. The problem was that this was the age of the “everyone’s equal and so should be taught exactly the same and become average” type of school in Sweden. If you were below the average you got help to catch up, but if you were above the average you didn’t get any help at all. So the first few years of school was just simply boring, there was no challenges, nothing that could help me grow. That coupled with one of the two teachers picking on me, and me being bullied, also stuck around, and it didn’t take many years until I just couldn’t be bothered with school. I still have problems taking courses and classes. Just after I have started school, we (me and my mom) moved to a brand new apartment a little bit away. I could still walk to the old apartment without crossing any roads, still close to the forest and the school, so still a good neighborhood. However things soon took a turn for the worse… Suddenly a strange man moved into the apartment with us. It was quite hard for me, and I didn’t make his first time living with us very nice. Fortunately we soon started to get along, and as he is still married to mom we still see each other when I’m visiting. With him came other changes as well, the biggest was building a house in the countryside and moving there. The move also meant that I had to change school. For the first time I could not just walk to wherever I needed, I had to take a bus to go to school. That wasn’t really a big deal fortunately, and I enjoyed the walks to the bus-stop. What was worse that the bullying didn’t stop, and neither did my distaste for school in general. I still got a couple of friends, even if no-one was very close. As a side-note, one of the bullies (the worst one) whom I really hated at first, I soon just despised. The reason was that he only bullied me when others were around, once we were alone on our own he tried to suck up to me like he never bullied me at all. He still continue to bully me, but I couldn’t care less about him anymore after that. After grade 6, in 1986, we had to go to the last three grades in another school quite a bit away. The bullying didn’t stop completely, but as school took more time and effort it died down quite a bit. But by then it was really too late for me, the insecurities and mental trauma never went away and I still have those scars inside of me, still affecting my life. By now my distaste for school started to bloom, and I started to skip classes. I even skipped whole days sometimes, staying at home without mom or my stepdad knowing (as far as I know… :-)). Other than that things were better than they had been for a long time, and my memories of those years are that it was rather decent. One of my strongest memories from there are the smell of the sugar refinery. In the autumn when the sugar-beet harvest season is upon us, and the closest (and these days Sweden’s only) sugar-refinery is running, when the wind is right I can feel the smell and it brings me right back to these years. After elementary school ended I went to “gymnasium” (upper secondary school) where I was studying technical engineering. Lots of math, some chemistry, biology, a little architecture, and other related subjects. I really wanted to study, but the spark just wasn’t there. All the previous years just had destroyed it. Worst however was the German as a third language studies I elected. I just couldn’t stand the teacher. Our chemistry was just wrong, and at the end she told me that I wouldn’t be failed if I just came to the very last class. Other than that I got some new friends that I spent some time with, but by then also my insecurities was in full effect so I just couldn’t trust some of them completely. I still spent time and partied with them, but whenever I heard talk that some was doing things without me it felt like they just din’t want me. A feeling I can still feel some times even now. And talking about partying, this was the time when started to drink alcohol. And drank we did. I had blackouts, I got sick, I got lift home once by the police. And we drank the cheapest and worst drinks known to man, either because they were cheap or because it had a lot of alcohol. We had rather fun though. In my second year here, I rented a room at my paternal grandmother, and moved away from home part-time. Still went home on weekends and hiatuses and between terms. In my third year I opted for electrics and electronics. For my fourth and last year I had to move to Stockholm. There I first lived with my stepdads parents and later shared an apartment with a couple of guys that was also from Gotland. I was lucky that one of the guys from my earlier class also went together to study the same, so I had at least someone I knew, because by then I had rather large problems making friends. This year I studied computers and communication. However I didn’t finish. As before I just couldn’t be bothered with classes that didn’t interest me, and I knew I would be failed in some classes. So I just packed my things and went back home to Gotland a week early.Intro for sci-fi / horror movie
Simple function-call tracing in C++
There are many ways to do function-call tracing in C++, where the simplest method is to just print "Entering function X"
when entering the function, and right before returning print "Leaving function X"
. It’s a lot of work though, especially if the function have multiple return
statements.
One solution to the problem above is to use a trace object. You create a class whose constructor prints the entering message, stores the function name, and whose destructor prints the leaving message. Then create an instance of this class as a local variable. When the object is instantiated, which happens when the function is called, the enter message will be printed. And when the function leave, no matter when or where or how it happens, the object will be destructed and the leave message will be printed.
Now how should such a class look like? It could be something simple like this:
struct tracer
{
std::string name_; // Name of the function
tracer(std::string const& name)
: name_(name)
{
std::clog << "Entering function " << name_ << std::endl; // Flushing is important
}
~tracer()
{
std::clog << "Leaving function " << name_ << std::endl; // Flushing is still important
}
};
That’s the basic of what is needed.
Now to use it is very simple:
void some_class::some_member_function()
{
tracer _unique_name_{"some_class::some_member_function");
// Lots of code and multiple `return` statements...
}
That is the basic usage. It has some drawbacks, in that tracing will always be enabled. It’s seldom needed for release builds for example, so only using it when a _DEBUG
macro is defined is a good start. It might be even better to have a special TRACING_ENABLED
macro so it can be enabled even in release builds which can be useful some times. Extra logic could also be added to check for flags set at run-time.
Here is an example full solution that uses preprocessor macros to enable and disable tracing at the time of compilation.
#pragma once
#ifndef TRACING_H
#define TRACING_H
#include <string>
#include <iostream>
#include <iomanip>
// Simple structure to handle function-call tracing.
// On debug builds, always build with tracing enabled unless explicitly disabled
#if defined(_DEBUG) && !defined(TRACING_DISABLED)
# define TRACING_ENABLED
#endif
// Define a preprocessor macro to help with the tracing
#ifdef TRACING_ENABLED
# define TRACE() tracing::tracer _tracer_object__ ## __COUNTER__ {__func__, __FILE__, __LINE__}
#else
# define TRACE() // Nothing
#endif
#ifdef TRACING_ENABLED
namespace tracing
{
class tracer
{
public:
tracer() = delete; // Disallow default construction
tracer(tracer const&) = delete; // Disallow copy construction
tracer(tracer&&) = delete; // Disallow move construction
tracer& operator=(tracer const&) = delete; // Disallow copy assignment
tracer& operator=(tracer&&) = delete; // Disallow move assignment
tracer(std::string const& fun, std::string const& file, int const line)
: function_name{fun}, file_name{file}, line_number{line}
{
std::clog << "TRACE: Entering function " << function_name << " (" << file_name << ':' << line_number << ')' << std::endl;
}
~tracer()
{
std::clog << "TRACE: Leaving function " << function_name << std::endl;
}
private:
std::string function_name;
std::string file_name;
int line_number;
};
}
#endif // TRACING_ENABLED
#endif // TRACING_H
Sample program using the above header file:
#include "tracing.h"
struct foo
{
int bar(int value)
{
TRACE();
if (value < 10)
return value * 2;
else
return value * 3;
}
};
int main()
{
TRACE();
foo my_foo;
my_foo.bar(20);
my_foo.bar(5);
}
The output from the program as shown above could be something like
TRACE: Entering function main (/home/X/Y/main.cpp:18) TRACE: Entering function bar (/home/X/Y/main.cpp:7) TRACE: Leaving function bar TRACE: Entering function bar (/home/X/Y/Testing/main.cpp:7) TRACE: Leaving function bar TRACE: Leaving function main
Output may vary depending on the compiler being used.