<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1448355248842203910</id><updated>2011-07-28T07:04:39.664-07:00</updated><category term='C++'/><category term='static blocks'/><title type='text'>Vesko Georgiev's blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://veskogeorgiev.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1448355248842203910/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://veskogeorgiev.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Vesko Georgiev</name><uri>http://www.blogger.com/profile/04516250253373309558</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1448355248842203910.post-7973874652175571577</id><published>2010-05-02T05:06:00.000-07:00</published><updated>2010-05-02T05:22:09.379-07:00</updated><title type='text'>Qt 4.6 on Snow Leopard</title><content type='html'>Hi folks.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lately I've been trying to get QT 4.6.2 installed on my Mac. Well that's not that easy as it turned out. Qt 4.6 does have a bug in the installer for Snow Leopard. It just fails in the end. A little googling shows that you need to remove Documentation and Examples from the installation. How the hell you do that? Well, I managed to fix it as follows:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Download the latest installer from the Qt site(mine was 4.6.2).  The file is QtSDK.mpkg. Rename the file to QtSDK. Yes, thats a regular directory, so just go inside with Finder. Go in Contents. Open Info.plist. There is a key called "IFPkgFlagPackageList". It contains an array of the subpackages to be installed. Just remove the keys for values Qt_examples and Qt_docs. Save the Info.plist. Go into QtSDK/Contents/Packages and delete Qt_examples.pkg and Qt_docs.pkg (don't know if that's really necessary). Then rename the QtSDK to QtSDK.mpkg again. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There you go. Double click and you should see Installation SUCCESS.  Then you can just run again the original installer so you can get the docs and the examples.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1448355248842203910-7973874652175571577?l=veskogeorgiev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://veskogeorgiev.blogspot.com/feeds/7973874652175571577/comments/default' title='Коментари за публикацията'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1448355248842203910&amp;postID=7973874652175571577' title='0 коментара'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1448355248842203910/posts/default/7973874652175571577'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1448355248842203910/posts/default/7973874652175571577'/><link rel='alternate' type='text/html' href='http://veskogeorgiev.blogspot.com/2010/05/qt-46-on-snow-leopard.html' title='Qt 4.6 on Snow Leopard'/><author><name>Vesko Georgiev</name><uri>http://www.blogger.com/profile/04516250253373309558</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1448355248842203910.post-8887461860970628187</id><published>2008-10-08T12:21:00.000-07:00</published><updated>2009-07-11T05:57:50.025-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='static blocks'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Java like static blocks in C++</title><content type='html'>&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;Hi there. I recently moved from java to c++ and I needed a java like static block, but realized that there is no "static { ... }" in c++ so this post is about static blocks in c++, why we need them and how do we write java like static blocks is c++.  &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let me have a class like this:&lt;/div&gt;&lt;div&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(127, 0, 85);font-family:Monaco;font-size:12px;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p face="Monaco" size="12px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(127, 0, 85);"&gt;class&lt;span style="color: rgb(0, 0, 0);"&gt; demo_class&lt;/span&gt;&lt;span style="color: rgb(0, 80, 50);"&gt; &lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(127, 0, 85);font-family:Monaco;font-size:12px;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="color:#000000;"&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style="color: rgb(0, 0, 0);"&gt;: &lt;span class="Apple-style-span" style="color: rgb(127, 0, 85);"&gt;static&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 80, 50);"&gt;vector&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;&lt;/span&gt;int&lt;span style="color: rgb(0, 0, 0);"&gt;&gt; stat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 192);"&gt;v&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p    style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:12px;color:#7f0055;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;public&lt;span style="color: rgb(0, 0, 0);"&gt;: demo_class(&lt;span style="color: rgb(127, 0, 85);"&gt;int&lt;/span&gt; i) {&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:12px;"&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="color:#000000;"&gt; &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;printf&lt;/span&gt;(&lt;span style="color: rgb(42, 0, 255);"&gt;"%d\n"&lt;/span&gt;, stat&lt;span style="color: rgb(0, 0, 192);"&gt;v&lt;/span&gt;[i]);&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:12px;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:12px;"&gt;     };&lt;/p&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:12px;"&gt;/* if you miss this line here, the linker will cry that it can't find a definition for this demo_class::stdev */&lt;/p&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:12px;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:12px;"&gt;&lt;span style="color: rgb(0, 80, 50);"&gt;vector&lt;/span&gt;&lt;&lt;span style="color: rgb(127, 0, 85);"&gt;int&lt;/span&gt;&gt; demo_class&lt;span style="color: rgb(0, 0, 192);"&gt;::statv&lt;/span&gt; = vector&lt;&lt;span style="color: rgb(127, 0, 85);"&gt;int&lt;/span&gt;&gt;(); // line x&lt;/p&gt;&lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:12px;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:12px;"&gt;    And I want this statv vector to be filled with some values before we create an object of this demo_class. The trick here is to define a global static variable of some type and to use its default constructor as a static block. The exercise is even more difficult if the static members are private. But the c++ language has tools for that too. What I need to do is to define this help type, in this case it will be a structure, in demo_class and mark it as "friend" in order to have access of the private static members. Add this `&lt;span class="Apple-style-span" style="color: rgb(127, 0, 85);"&gt;friend&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;struct&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 80, 50);"&gt;static_block&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;`&lt;/span&gt;&lt;/span&gt; after the constructor. Now I have declared a friend type of our class. I still don't have a definition of this type and I'll do it outside the class definition in а .cpp file just before i create an object from this type static_block. The code goes like this:&lt;/p&gt;&lt;p face="Monaco" size="12px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p face="Monaco" size="12px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-style-span" style="color: rgb(127, 0, 85);"&gt;static&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;struct&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 80, 50);"&gt;static_block&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p face="Monaco" size="12px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;static_block() {&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(42, 0, 255);font-family:Monaco;font-size:12px;"&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="color:#000000;"&gt; &lt;/span&gt;&lt;/span&gt;printf&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;"static_block()\n"&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(42, 0, 255);font-family:Monaco;font-size:12px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;/* you can miss this line here only if you declare _STATIC_BLOCK_INSTANCE after line x. That way you are shure that demo_class::statv will be created and you can use it.*/&lt;/span&gt;&lt;/p&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(42, 0, 255);font-family:Monaco;font-size:12px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 80, 50);"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="color:#000000;"&gt; &lt;/span&gt;&lt;/span&gt;demo_class&lt;/span&gt;::stat&lt;span style="color: rgb(0, 0, 192);"&gt;v&lt;/span&gt; = &lt;span style="color: rgb(0, 80, 50);"&gt;vector&lt;/span&gt;&lt;&lt;span style="color: rgb(127, 0, 85);"&gt;int&lt;/span&gt;&gt;();&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px;  font-style: normal; font-variant: normal; font-weight: normal;  line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:12px;"&gt;&lt;span style="color: rgb(127, 0, 85);"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="color:#000000;"&gt; &lt;/span&gt;&lt;/span&gt;for&lt;/span&gt; (&lt;span style="color: rgb(127, 0, 85);"&gt;int&lt;/span&gt; i = 0; i &lt;&gt;&lt;/p&gt;&lt;p   style="margin: 0px;  font-style: normal; font-variant: normal; font-weight: normal;  line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:12px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 80, 50);"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="color:#000000;"&gt; &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;demo_class&lt;/span&gt;::stat&lt;span style="color: rgb(0, 0, 192);"&gt;v&lt;/span&gt;.push_back(i * i);&lt;/p&gt; &lt;p   style="margin: 0px;  font-style: normal; font-variant: normal; font-weight: normal;  line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:12px;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p   style="margin: 0px;  font-style: normal; font-variant: normal; font-weight: normal;  line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:12px;"&gt;}&lt;span class="Apple-style-span"   style="  ;font-family:Monaco, fantasy;font-size:12px;"&gt; _STATIC_BLOCK_INSTANCE;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;    So this is it. The code should work. But remember don't try to use c++ as java ... you will not go any further.  &lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1448355248842203910-8887461860970628187?l=veskogeorgiev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://veskogeorgiev.blogspot.com/feeds/8887461860970628187/comments/default' title='Коментари за публикацията'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1448355248842203910&amp;postID=8887461860970628187' title='1 коментара'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1448355248842203910/posts/default/8887461860970628187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1448355248842203910/posts/default/8887461860970628187'/><link rel='alternate' type='text/html' href='http://veskogeorgiev.blogspot.com/2008/10/hi-there.html' title='Java like static blocks in C++'/><author><name>Vesko Georgiev</name><uri>http://www.blogger.com/profile/04516250253373309558</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1448355248842203910.post-197549852247426527</id><published>2008-09-23T15:13:00.000-07:00</published><updated>2008-09-24T12:33:45.589-07:00</updated><title type='text'>First one</title><content type='html'>Hey, folks. This is my first blog. So I have a few ideas in mind to write about. They are just things that took me some time to figure out. Not just coding but any gigs you can do with your computer. My first serious blog coming soon...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1448355248842203910-197549852247426527?l=veskogeorgiev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://veskogeorgiev.blogspot.com/feeds/197549852247426527/comments/default' title='Коментари за публикацията'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1448355248842203910&amp;postID=197549852247426527' title='0 коментара'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1448355248842203910/posts/default/197549852247426527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1448355248842203910/posts/default/197549852247426527'/><link rel='alternate' type='text/html' href='http://veskogeorgiev.blogspot.com/2008/09/first-one.html' title='First one'/><author><name>Vesko Georgiev</name><uri>http://www.blogger.com/profile/04516250253373309558</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
