(As of 2013/05/11 there is a quick addendum at the end of the post)
This is a very quick post because it’s a very simple update to two posts from quite some time ago. I had discussed how to find C style casts in C++ source code and at the time of the first post I was thinking in casting to pointers. Then I made another post with to note that fact and a possible way to find all.
Well, there is a much better way. What is it ? With the g++ compiler you let it show you, that’s the way. How do you do it ? Use the option to g++:
and recompile all object files (if you use make you may very well have a make target called ‘clean’ then you could just run ‘make clean’ and then ‘make’).
g++ will then show you where every old style cast is used in the project’s source tree (that it encounters). Now it’s simply a matter of determining which new cast type you should be using for the specific cast, fix and recompile again. It’s that simple.
Addendum: Okay, to be truthful it is not entirely ‘that simple’. Yes, this is how to find the old style casts in YOUR source code but it should be noted that there are some system calls that are implemented as #define macros and do use the old style casts. There’s nothing you can (or should do) about those. Examples that come to mind are:
FD_* macros used for the select(2) system call.
WEXITSTATUS (and most likely the other related) macros for the wait(2) system call.
That all said the option is useful to use at times if you want to be sure your own source code does not use old style type casts.
This is obviously not a technical piece but it is something that is important for me so I’m writing it before I forget about it. I regret that missed several other significant deaths including indeed Ronnie James Dio of Black Sabbath (and others) and more recently Jon Lord of Deep Purple. Today is yet another sad day for metal music, an important part of my life.
I am even more upset now that health prevented me from seeing Slayer when I actually had tickets (in 2011) because Jeff is now gone. He was an amazing guitarist and his music will be well missed. The fact he died from liver failure and that I have a very close friend with liver disease as well as having lost family to liver disease, this really hits me hard. I typically do not think of the past and although that may be sad at times (hard to think of good memories in the past without thinking of the past) I would say it generally helps me cope with losses.
There really is not much else to say as this is truly a horrible loss to the metal heads of the world.
R.I.P. Jeff and thanks for your time and dedication with Slayer.
It has been a LONG time since I wrote anything here and I have updated very little elsewhere (I did update some of the documents at http://docs.xexyl.net and I changed the main menu here a little bit but that is about it). The reason for such is a lot of health problems and such is life. While there’s a lot of stuff I have thought to write about the truth of the matter is they are quite low on my priority list. Nevertheless, since the topic in question is something easy enough (read: it’s not a lot to cover) to write about and since I have seen many people complain about the very warning by the Postfix mail server yet not find a solution I decided to spend a few minutes to write how to solve it. The complaints that are heard are typically along the lines of two themes :
But I do not have my domain in both mydestination and virtual_mailbox_domains!
There’s no explanation on how to get rid of this warning (aside from the ‘work around’ option to disable warnings) in the documentation.
Well, each has its problems but I will sort this out for those who have the warning I refer to. For the first problem, you must understand that just because you do not specify mydestination does not mean it is not set. Further, there is the chance there’s more than one instance of Postfix running (though to be fair this is less likely the problem). The second problem is not entirely true although maybe it should be made very clear in the documentation. That’s not up to me though.
So how do you solve the problem then? First, we’ll assume that your domain names are two of the for-documentation purposes domains:
We’ll also assume that the mail server is specifically example.com and you want either both to be a virtual domain or you want example.org to be the virtual domain. Choose your poison when reading this as it really does not matter in the slightest with this configuration.
So given the above parameters this is what you need to do :
- The server’s name should be what mydestination is set to, so in the configuration file (main.cf which is generally under /etc/postfix/main.cf) you need the line:
- mydestination = example.com
- Next, assuming you have you your virtual domains file (a plain text file, one entry domain name per line) named (also in /etc/postfix/) virtual_domains then you should (adjusting to whatever your file name is) have the following in your main.cf file :
- virtual_mailbox_domains = virtual_domains
Note that if your file is actually a database file then you would need to adjust the line above to let Postfix know this (e.g., prepending ‘hash:’ without the quotes to virtual_domains and if you have updated the file do not forget to update the database file with for example postmap). It should go without saying but example.com (the final destination) should NOT be in the virtual domains file.
- The last step is essentially masquerading mydestination as a virtual domain (in the sense of the effect of the end result). Here Postfix is informed that local transport is to use the virtual transport service and that the local recipients are included in the virtual domains. That is possibly not the best way to word what is going on but the two lines should show all that is needed to understand it :
- local_transport = virtual
- local_recipient_maps = $alias_maps $virtual_mailbox_maps
Assuming that Postfix virtual mailbox and virtual domains already worked then this, combined with reloading or restarting Postfix should be all you need to do. There is a way to ‘force’ Postfix to issue the warning (in the case that it’s not configured properly) but I do not have the motivation to write about it.
Hopefully this has been of help to some people and to those who I have left some questions remaining, I am sorry in advance. The real key is that your server name is the final destination and it is masqueraded as a virtual domain (but actually it is not in the truest sense of the word). This does however mean you might need to set up local users mail if they are to receive mail. I’m afraid you’re on your own there but if you only wanted virtual domains this should not be a real problem any way. Lastly, I am sorry if I have left anything out. As I said I have been quite unwell for some time and I may very well have neglected to mention something important. No idea when I’ll be writing next. Until then, so long and thanks for all the fish (yes, a little tribute to Douglas Adams as I missed his 61st birthday in March).
Update on 2012/10/15:
I fixed an unfinished thought regarding installing CentOS (below). Indeed I have not updated anything of late as I have been quite unwell. There has been a more recent update of GCC (if I recall) but I’ve not been well enough to do anything with it for the Xexyl repository. I did at one point make a static package for gcc47 (so you don’t have to use shared libraries). Also, although the backport is potentially useful, there’s another option too. Depending on the environment it may actually be better. If you do have a need for more recent GCC releases and you prefer using just ‘gcc’, ‘g++’, etc., or even just want the system as ‘clean’ as possible, you could use VirtualBox and install the latest Fedora (which will have the latest GCC, generally speaking). It also allows for a completely different environment in the server, so that everything is separate. Otherwise, you are welcome to use my backport (that’s what it is there for). Lastly, I do not know when I’ll be writing again (due to health) but hopefully sooner than later. There have been several things I’ve wanted to write about in the past 3 months but I’ve just not been up to it.
Update on 2012/07/11:
I now have built the packages for i386/i686 architectures. So that means whether you use CentOS 6.x x86 or CentOS 6.x x86_64 you can make use of the packages. I did notice yesterday that CentOS 6.3 is out so I will likely build for that too in time, but note however the packages work for 6.3. as is so it’s not high on my priority for the moment.
I will document this and put it in a specific location and update this post when I do, but I wanted to introduce everyone to the Xexyl CentOS 6 RPm Repository. Yes, it’s true – you can now install gcc 4.7.0 under CentOS 6 in a safe way (I stopped working on CentOS 5 because I don’t have a need for that now. Considering CentOS 6, 6.1, and 6.2 are already out, I would highly suggest anyone installing a new CentOS install to use the latest). Not only that, you can do it without having to build the RPMs yourself. Indeed, thanks to a good long time friend of mine, I have a CentOS 6 RPM repo (along with yum files so you can easily update) and it is hosted on 2 servers each with a much faster connection than mine.
There is a cron job on the servers to sync from my server. It’s a nightly cron, so if I find any mistakes, or more likely – an updated GCC – it will be quickly adjusted (as long as I’m well and able to build it).
So, quick run down of how to get the Xexyl Repository installed :
# rpm -Uvh http://rpm.xexyl.net/redhat/6/noarch/RPMS/xexyl-release-6-1.noarch.rpm
That’s pretty much it. You should be asked (when first installing a Xexyl RPM package) if you want to install the GPG key and that is generated specifically for this reason. It means you can make sure the software in the repository is signed with this key (and the update program will make sure, as long as you don’t disable checking of the GPG key). So in short, just accept, and then you can install the programs via yum. Alternatively, you can install specific rpm files from the repository via yum or rpm.
Now, one last thing for this. How do you install gcc 4.7.0 in CentOS 6.x? After installing the Xexyl Repo package, simply type this command :
# yum install gcc47 gcc47-c++ libstdc++47 libstdc++47-devel libgcc47
That should be more than enough to pull in everything you might need. Oh, and yes, I should say that this allows for dynamic linking; indeed, you don’t have to statically link your binaries with this thanks to the GCC ABI policy: it allows for newer versions to work for older versions. Note you don’t need this if you’re in Fedora because Fedora already has the more recent gcc packages and indeed it will conflict with such.
Hopefully my server can be reached globally. That is a different story though, and one I’d rather not get into (thanks, ISP!). Indeed my IP has changed and it’s not even static now. Anyway, I have some better things to write about than that.
So, back in April I read about Linus Torvalds being nominated for the Millennium Technology Prize. I thought that was cool and he had a good chance of winning. Well, yesterday, it was announced that he DID in fact win. Not only did he win, he shares it with a scientist who studies something else I feel passionate about: stem cell research (generally I’m for medical research – we’d not be here if it were not for it and the fact stem cell is only 10-15 years old means it is still a very early thing. Sadly many think that’s enough time but they just can’t or don’t want to understand and realize how long other illnesses have been around and the fact we’re still not even close to “curing” them).
So, given that I’m a huge Linux fan, and have used it for close to a decade and before that used SunOS/Solaris, FreeBSD and other Unixes, I figure I would reflect on some things. I used to ‘hate’ Linux; I loved Unix but not Linux. That may seem a bit odd but let’s just say I fully admit I’m a bit closed (okay, okay! Very closed) minded about a lot of things. There is however a funny story about how I opened up to both Linux and also OOP – object oriented programming. Back somewhere in the early 2000s I had a project that mainly developed with Linux. Now, I was a developer but I had FreeBSD as my primary programming machine. I even contributed a patch to the linux_logo program to make it FreeBSD compatible. Still, I didn’t like Linux that much. But there’s something called priorities. So, considering that the project I was part of (and to this day still am) was using Linux, I actually was too. I just didn’t like it as much (in short : it was different and being rather closed off, it must not be that “great”).
Firstly though, there’s two computer languages that I’ve been the most fond of, of the 10+ (likely more, but I’m not going to bother counting and classifying which ones I used to which degrees) I’ve used. As one can imagine, one of them is C. The other is assembly. So, in other words, lower level (and low level) languages, both having direct access to memory etc. And it happens that this project I referred to was in C. It, I might add is a multiuser dungeon (MUD) – a type of game, essentially a MMORPG but all text [remember text games? I sure do] – that originally came online in 1994. Yes, its still around and yes I’m still a developer and in fact am rewriting it in (the horror…) C++ from scratch (yes, that’s the project I’ve referred to at times in the past year or so).
With that background and terrible attitude, how did I manage to prefer Linux and also like object oriented languages, perhaps more than the structural/procedural languaes ? Well, at some point, a good friend of mine – Martijn – one of the founders of said MUD above – wrote some psuedocode but it was a cross between C and C++. Of course, being the type to say something, I did. I don’t remember the exact words but it was something like how is that valid ? (In fact: in C it is but it is perfectly valid in C++). But I was procedural loon! I then made the even bigger (some might call this a stupid mistake; I say it allowed a huge revelation to start revealing itself, and a good one at that) wise mark. I said something like : Even Linus Torvalds doesn’t like C++ as its too bloated. Yes, that was a VERY ignorant remark on my part. Oh, sure he said something like that in the past, and it has good intentions: C is not a bad choice for, say, an operating system kernel. Still, that does not mean C++ is ‘bloated’. Even if it is, that doesn’t have to be bad bloat and some might see it as feature rich (then again, some seem to think the C++ standard library is lacking and is too slow in progressing. I beg to differ but I also realize how developing something that needs to remain stable and clean will work and progress and C++ has some pretty nice features that make things lacking easier to do). So, back to the story. What did my friend have to say about my ridiculous remark ? He said (know that he wasn’t insulting Linus and most certainly he loves Linux – perhaps more than me) something that rather put me in my place but in a good way. It was so good it’s when I started to realize how closed off and how much I was missing. He was blunt yet accurate. It was a good way to address it, especially for someone like me – a quite sarcastic and satirical person with a big mouth. He said the following:
You mean the same guy who created the bloated Linux kernel ?
Well, of course, I wasn’t stupid. He had a very good point. Yes, it is true that the bloat he refers to is support for different types of hardware and a lot of customizable options and many other features that are actually good features. Still, it is a VALID point too. It opened my eyes. Then, over the next 3-5 years I started loving Linux, far more than I ever did the other Unixes, and then I also started opening up to Java, C++ etc. That’s where I am today. While C and assembly has a lot to offer, and while it is dear to my heart, that doesn’t mean other things can’t be good or dear to my heart. That’s something that everyone should try to remember. Besides that, as they say, ‘good comes with bad’ (and vice versa). So, shortly, some times things aren’t exactly as you might seem to think. It might be better, it might be worse. It might not. But it does a person well to remember that we’re all different, we all have our quirks and we all have unique traits. I’m not only thankful that I’m willing to accept when I’m wrong (and willing to learn more as a consequence, no matter what I knew or didn’t know before), but I’m also thankful that I had a big mouth and actually said such an ignorant thing. Equally, I’m thankful for my friend putting me in my place: I’ve learned a lot from him, gained wisdom and also been given the opportunity to experience much, much more (even working on his MUD is a huge thing but his friendship and life experience is too).
Yes, this post is intended to be about Linus Torvalds and his kernel. But I think that’s a very relevant story and its a way to show that what may seem ‘evil’ or ‘bad’ may not be that evil or bad after all. Linux does bring a lot of people over the world together, a lot of awesome groups, team work, and many other things, not to mention the possibility for some very very powerful and flexibile operating systems. It being based on Unix makes it even better. As I often say, I can do so many things with a ‘simple’ command line under Unix and especially Linux (GNU extensions rule!) that you either have to do complex scripting for or get an entire program (which may not be free) in some other environment. That is awesome.
So, I extend my congratulations to Linus completely. You deserve it 200%. Thank you from the bottom of my heart, Linus, for the amazing work you do, be it the Linux kernel, git, whatever. You have no idea how much you help people (actually you probably do but the point is I cannot thank you enough).
Cheers and congratulations to Linus!