2015年2月5日 星期四

Different between const int * , int const * and int * const

* Question: 
What different between const int * , int const * , int * const ?

* Answer: 
  • int*                                                           - pointer to int
  • const int * == int const *                     - pointer to const int
  • int * const - const pointer to int
  • const int * const == int const * const - const pointer to const int

  • int **                       - pointer to pointer to int
  • int ** const             - a const pointer to a pointer to an int
  • int * const *           - a pointer to a const pointer to an int
  • int const **            - a pointer to a pointer to a const int
  • int * const * const - a const pointer to a const pointer to an int


* Reference: 

http://stackoverflow.com/questions/1143262/what-is-the-difference-between-const-int-const-int-const-int-const

2015年2月4日 星期三

Difference between std::thread and pthread

* Question: 

What are the differences between std::thread and pthread


* Answer: 
The std::thread library is implemented on top of pthreads in an environment supporting pthreads 
std::thread provides portability across different platforms like Windows, MacOS, and Linux, but may not be complete on all platforms yet.
The C++11 std::thread class unfortunately doesn't work reliably (yet) on every platform, even if C++11 seems available.

* Reference: 
http://stackoverflow.com/questions/13134186/c11-stdthreads-vs-posix-threads

2015年2月3日 星期二

Difference between size_t and std::size_t


* Question: 

What are the differences between size_t and std::size_t



* Answer: 
C's size_t and C++'s std::size_t are both same.
In C, it's defined in <stddef.h> and in C++, its defined in <cstddef> whose contents are the same 
as C header (see the quotation below). Its defined as unsigned integer type of the result of the 
sizeof operator.

* Reference: 
http://stackoverflow.com/questions/5813700/difference-between-size-t-and-stdsize-t


2014年9月17日 星期三

My environment : 8G RAM, Windows 7 64bit

Official document 


1. Install depot_tool
            Download and unpack to any folder you like, such as C:\Work\depot_tools
               
            Note:
            Do not use drag-n-drop or copy-n-paste extract from Explorer
            * Do not extract to a path containing spaces.
            
             Add a PATH user variable: %PATH%;C:\path\to\depot_tools

2. Initialize gclient
            Start -> cmd
            Execute gclient --version twice, twice is must.
            gclient --version
            gclient --version

3. Get source code
            Create a folder such as D:\Work\chromium
            Open cmd window
            cd D:\Work\chromium
            
            Get code
            fetch –nohooks chromium

            Create a branch named master 
            (The master is different with origin/master)
            cd src
            git checkout master

            Install some necessary tools by gclient
            gclient sync

4. Build code
            set GYP_DEFINES=component=shared_library
            python build\gyp_chromium
            ninja -C out\Debug chrome.exe


l   Trouble Shooting:
Error (gclient sync)
Running sdksetup.exe to download Win8 SDK (may request elevation)...
Windows 8 SDK failed to download, retrying.
Windows 8 SDK failed to download, retrying.
Windows 8 SDK failed to download, retrying.
Windows 8 SDK failed to download, retrying.
Windows 8 SDK failed to download, retrying.

Solution
Remove proxy setting.


Error (gclient sync)
Error: Command svn checkout https://cld2.googlecode.com/svn/trunk@157 D:\Blink\src\src\third_party\cld_2\src --revision 157 --non-interactive --force --ignore-externals returned non-zero exit status 1 in D:\Blink\src
Solution
        Execute svn ls https://cld2.googlecode.com/svn/trunk,choose 'accept' for conflict prompt.


Error (build code)
Warning C4819: The file contains a character that cannot be represented in the current code page (932). Save the file in Unicode format to prevent data loss
Solution
        You may use Chinese, Japanese or Korean Windows, and uses DBCS code page.
        You need to change your Windows system code page to English or another SBCS code page. You can do this by Control Panel - Regions - Administrative - Language for non-Unicode programs.




Debug

1.      Execute out\Debug\chrome.exe
2.      Start Visual Studio (Any version)
3.      In Visual Studio menu bar, Select Tool->Attach to Process-> Select the chrome process.
4.      Pull a file you want to set breaking point into Visual Studio and enjoy it.



Install VBox Guest Additions

The steps to install Guest Additions for Virtual Box.

1. Start you Linux.
2. Select 'Devices' on V-Box menu.
3. Select 'Insert Guest Additions CD Image'
4. Open Terminal appilcation.
5. Execute cd /media/VBOXADDITIONS_4.3.10.93012
6. Execute sudo sh VBoxLinuxAdditions.run

Done.

* If you got error message in step 3 'Unable to mount the CD/DVD image C:\#######\VBoxGuestAdditions.iso on the machine Ubuntu-##.##. Would you like to force mounting of thins medium?'
   Please select 'Device->CD/DVD Devices->Remove disc from virtual drive' and try again.


2014年7月31日 星期四

[GCC] error : Sleep was not declared in this scope

Situation:
I got error message when I compiling my c++ code with sleep(1); inline.
"error : Sleep was not declared in this scope"


Solution:
The solution is add folling including message in the head of your code.
#include <unistd.h>


Reference:
http://stackoverflow.com/questions/10976176/c-error-sleep-was-not-declared-in-this-scope

2014年5月27日 星期二

[Linux] Check linux kernel is 32 bit or 64 bit

Problem:

How to check linux kernel is 32 bit or 64 bit



Command:
Input following command in terminal.

uname -m
OR
file /bin/bash


Example:
allen@www ~/work$ file /bin/bash
/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

allen@www ~/work$ uname -m
x86_64


Reference:
http://www.linuxquestions.org/questions/linux-general-1/how-to-check-linux-kernel-is-32-bit-or-64-bit-612352/
http://blog.longwin.com.tw/2011/01/linux-check-32-64-bits-2011/

2014年3月28日 星期五

[Linux] Disk quota exceeded

Problem:
I got following message when I am trying to remove some files.

$ rm cmakeconfig.h

rm: cannot remove `cmakeconfig.h': Disk quota exceeded

Solution:
We could use command 'wipe' to delete some file for more disk space and execute rm later on.

$ wipe CMakeCache.txt

Wipe CMakeCache.txt

delete CMakeCache.txt

done


2014年3月21日 星期五

Find string and files on linux

To find files at linux bash command.

$ find [path] -name 'filename'


To find string in files at linux bash command.

$ find [path] | xargs grep 'string'



2014年3月1日 星期六

[Webkit] Debug QtWebkit with Visual Studio 2010.

1. Install Tools

  • Install Visual Studio 2010
  • Install VS2010 SP1.  (http://www.microsoft.com/zh-tw/download/confirmation.aspx?id=23691)


2. Get qt source code
Doload qt 4.8.5 from following address.
http://download.qt-project.org/official_releases/qt/4.8/4.8.5/qt-everywhere-opensource-src-4.8.5.zip

Decompress qt source code at D:\qt-4.8.5


3. Add path
Add D:\qt-4.8.5\bin to the Path variable


4. Run Visual Studio 2005 Command Prompt
Execute following commands in the VS command prompt:
cd D:\qt-4.8.5

configure –opensource -confirm-license –no-qt3support –debug –webkit –platform win32-msvc2010
Wait few minutes.

Remove the illegal quote characters  and ” at line 327 in
D:\qt-4.8.5\src\3rdparty\webkit\Source\WebCore\platform\DefaultLocalizationStrategy.cpp if VC stops compiling this file.

Execute following command in the VS command prompt:
nmake

5. Debug Webkit
Use VC 2010 to open and build D:\qt-4.8.5\src\3rdparty\webkit\Source\Webkit.sln
Set QtWebkit as start project.
Right click on QtWebkit project -> Properties -> Configuration Properties -> Debugging -> Set Command as C:\qt-4.8.5\examples\webkit\fancybrowser\debug\fancybrowser.exe
Start Debugging. (F5)


My operating system is Windows 7 (64bits).