I am pretty new to C++, so the question might sound stupid, but even though I googled quite some time, I could not find an answer. I am using the ROS environment, but my question should be a general C++ problem, so I decided to post it here.
I have two codes
ros::Duration max_storage_time = ros::Duration().fromNSec(1ULL * 1000000000LL);
tf::TimeCache odometryCache(ros::Duration max_storage_time = ros::Duration().fromNSec(1ULL * 1000000000LL));
The problem is that you're not linking properly with the ROS libraries.
The solution is to set up your linker properly.
Only the first one actually calls any ROS functions - the second declares a function that takes a
ros::Duration and returns a
tf::TimeCache (This is called "the most vexing parse").
If you never try to use
odometryCache, the second will not cause any problems.
If you do (for instance,
odometryCache.clearList()) the compiler will complain that you're trying to access a member of a non-aggregate type, or something along those lines.
If you don't try to name the constructor's argument:
tf::TimeCache odometryCache(ros::Duration().fromNSec(1ULL * 1000000000LL));
it will compile, but linking will fail just like for the first piece.