C++ fun with typedef and const

UPDATE. Well actually my previous assumption is wrong and the problem occurs because one type is pointer const vs other pointer data const.

I stumbled on some interesting problem today:

typedef char *MY_KEY;
 
void foo (const MY_KEY key)
{
// ...
}
 
int main (...)
{
 
const char *str = "some str";
foo (str);  // error: smth like unable to convert LPCSTR (const char*) to char*
 
}

Weird isn’t it? From first glance everything looks alright and I really didn’t understood why it was not working. After some googling I find out what is going on. Problem is that qualifier (const or others) applies at the very top level, in my situation once I typedef type with pointer qualifier can not be injected between type and a pointer. Here what is happening:

typedef char *MY_KEY;
void foo (const MY_KEY key) -> equals to -> void foo (const (char *) key)

Now to avoid this situation typedef should be done without pointer, like this:

typedef char MY_KEY;
 
void foo (const MY_KEY *key)
{
// ...
}
 
int main (...)
{
 
const char *str = "some str";
foo (str);  // and it works as it should
 
}

Wikipedia Forever

Could you imagine that wikipedia, this amazing resource is still free ? Now, when everybody tries to make some money with any traffic and wikipedia 7ranked (Alexa) site in the whole world doesn’t. Its fantastic resource where I could spend hours whenever I need some reliable information on any topic in the world or I am bored and just read whatever comes. Sometimes I even don’t google anymore I use wiki instead, even if I do I am using it something like – <topic> “wiki”. Its irreplaceable resource for any person who is constantly learning something new.

I hope it will remain free and won’t become some commercial giant, because then it won’t be a great loss, because it would lose the idea, the essence. Wikimedia Foundation needs donations now. I am encouraging any habitual wiki user to donate at least few bucks. I guess, if all users would donate at least 1$ the current target goal 14$ million would be reached quite easily. So, do it now:

Wikipedia Affiliate Button

Color Inspiration

Lately, I got a problem in my painting experience, somehow I got stuck with one color scheme and just can’t get rid of it. So I decided to look up for some new inspiration on web. Basically I thought to look for various painting galleries with some good quality(reasonable resolution) images. Of course this means I had to do some googling, some brute-force googling, because now-days you have to climb through a pile of commercial/spam sites to find something good. Well, but it was worth it, I found some good resources, they will surely give me some ideas and stir up my creativity for a while. Here they are, in no particular order:

So that’s it. Plenty of inspiration for me.. And I am going to add some more later.

Painting in Acrylics

Added new page Paintings. Here I will add all my new creations in acrylics media. Well these creations are nothing special so far as I am just starting to learn and feel this new world. It is still a very new area to me. Most of the time, since my teenage years I was doing graphics mostly with graphite or ink. But at some point in my life I found this completely new world – the world of color.  I was amazed by impressionism and for some time I was trying painting using oils, just before starting my studies in computer science. But oils for me was very demanding media – it was drying very slowly and you couldn’t paint in a living room because of the smell. Since I was living in a student dorm with some other fellow students, oils were not an option.  Later  I tried watercolors, but it was just too much for me – such an unforgivable  media. However the story with acrylics is completely different, after I found this media, I just can’t stop admiring it. And here is why:

  • There is no bad smell, actually no smell at all or at most it is very mild one, like watercolors for example.
  • Acrylics dries fast. And you can dry them even faster, for example using your wife’s old hair dryer.
  • If you like to stop them from drying too quickly just keep them wet by using simple water atomizer.
  • You can work with acrylics as with watercolors or oils. It just takes what is best from both medias.
  • Acrylics surface is mat then dried, but if you want your work to be gloss just use any gloss varnish.

And sometimes I can’t understand why people are even bothering with oils, acrylics are so much better. Well, but probably people just like what they are used to and why would anyone need to change his “tool” when he have already mastered it. But if you ever doubt what you should start with I would say – acrylics, definitely.