Friday, September 28, 2012

Boost 1.48+, BOOST_JOIN, and Qt

(September 29, 2012)

I am using Visual C++ 2010, Boost Library, and Qt (of course, with some other libraries such as OpenCV, but they are not relevant). This combination can lead to headache if Boost version is 1.48+ (mine is 1.51) and Qt 4.7.3+ (mine is 4.8.3).  The problem prevents us from successful compile and we will get Parse error at "BOOST_JOIN". The error message I got from Visual C++ 2010 is boost_1_51_0/boost/type_traits/detail/has_binary_operator.hp(50): Parse error at "BOOST_JOIN”.  This problem occurred during Qt’s Moc'ing.

A file in Boost that causes this error message can be varied.  Mine was boost/type_traits/detail/has_binary_operator.hp, but other people seemed to encounter a similar error in other files.  The discussion is available at https://bugreports.qt-project.org/browse/QTBUG-22829.  The cause of the issue is Qt’s moc.exe. 

Fortunately, we can solve the issue by doing something with moc’s parameters. To be exact, we can solve the issue by sending an option 
-DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED 
to moc. If you install Qt VS Addin, you can right click a project and choose ‘Qt project settings.’ There, you set the MocOptions as shown in a figure below.

image

Monday, January 02, 2012

Prevent Autorun/Autoplay of USB Drives

(Jan 2, 2012)
Many old machines in Silpakorn Computer Labs are still using Windows XP and I need to disable Autoplay from USB devices to avoid virus spreading from the devices to these machines.  Luckily, the XP is Professional version and it is easy to disable the Autoplay.
Details on how to disable the Autorun functionality in Windows are available at http://support.microsoft.com/kb/967715/en-us.  Here, I discuss only Windows XP Professional (Home edition is harder to deal with regarding this matter).  For Windows 7, you can see this video to learn how to disable USB Autoplay. The method for Windows XP Professional is described below:
  1. Click the start button and click ‘Run …’
  2. Insert command ‘Gpedit.msc’ and enter.
  3. Under Computer Configuration, expand Administrative Templates, expand Windows Components, and then click Autoplay Policies.
  4. In the Details pane, double-click Turn off Autoplay.
  5. Click Enabled, and then select All drives in the Turn off Autoplay box to disable Autorun on all drives.
  6. Restart the computer.
Side notes: many people think that autorun and autoplay are the same thing.  The idea is right in one sense and wrong in another.  As far as I know, Autorun is some thing for running the CD/DVD contents automatically.  Autoplay, however, seem to be broader and is applicable to any USB devices.  So, the behaviors of Autorun and Autoplay are practically the same, but Microsoft gave them different names.