2012年8月13日 星期一

Android - build error and solution

Error 1 :

host C++: libutils <= frameworks/base/libs/utils/RefBase.cpp

frameworks/base/libs/utils/RefBase.cpp: In member function ‘void android::RefBase::weakref_type::trackMe(bool, bool)’:

frameworks/base/libs/utils/RefBase.cpp:483:67: error: passing ‘const android::RefBase::weakref_impl’ as ‘this’ argument of ‘void android::RefBase::weakref_impl::trackMe(bool, bool)’ discards qualifiers [-fpermissive]make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误 1

Solution :

$ gedit frameworks/base/libs/utils/Android.mk
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)

Modify to ...

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive

Reference link : http://goo.gl/gb2XC

Error 2 :
host Prebuilt: monkeyrunner (out/host/linux-x86/obj/EXECUTABLES/monkeyrunner_intermediates/monkeyrunner) host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp <命令行>:0:0: 错误: “_FORTIFY_SOURCE”重定义 [-Werror] :0:0: 附注: 这是先前定义的位置 cc1plus:所有的警告都被当作是错误

Solution :

build/core/combo/HOST_linux-x86.mk line 61: 

find this line ...

-HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0

modify to ...

+HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

Reference link : http://goo.gl/kUEpI

2012年5月28日 星期一

CE : Error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.UnsafeValueTypeAttribute..ctor'

Error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.UnsafeValueTypeAttribute..ctor'

Solution:
Update your project to .NET 3.5 in your VS2008.

2012年5月25日 星期五

C/C++ : 位元判斷與改變

其實只是做個筆記,懶的背起來,免的每次要用又要想一下。

判斷某一個 flag 有沒有被 enable : &
enable 某一個 flag : |
disable 某一個 flag : ~&

example :


unsigned int g_dwFlags;
void Enable(unsigned int dwFlags)  {  g_dwFlags |= dwFlags;  }
void Disable(unsigned int dwFlags) {  g_dwFlags &= (~dwFlags);  }

資料來源 : http://www.csie.nctu.edu.tw/~skyang/bitwiseshift.zhtw.htm


2012年5月24日 星期四

VC/C++ : LINK : fatal error LNK1000: Internal error during IncrBuildImage

VC/C++ compiler 出現錯誤 : LINK : fatal error LNK1000: Internal error during IncrBuildImage

Solution : 
專案 -> 屬性 -> Debug -> 啟用累加連結 -> 否(/INCREMENTAL:NO)


資料來源 : http://www.cnblogs.com/happytogether/archive/2010/04/22/1718182.html

2012年5月23日 星期三

VC/C++ : fatal error C1010

VC/C++ compiler 出現錯誤訊息 :  fatal error C1010: 尋找先行編譯標頭檔指示詞時碰到未預期的檔案結尾。您的原始檔中是否忘了加上 '#include "stdafx.h"'?

Solution:
專案 -> 屬性 -> 組態 -> 所有組態
組態屬性 -> C/C++ -> 先行編譯標頭檔 -> 建立/使用先行編譯標頭檔 -> 未使用先行編譯標頭檔

VC/C++ : HRESULT:0x800736B1

一般只會出現在以 Debug 模式下的時候會出現的錯誤。

Solution :

專案 -> 屬性 -> C/C++ -> 執行階段程式庫 -> 多執行緒偵錯(/MTd)


2012年5月21日 星期一

C# - Reboot source code


using System.Management;
       
...      
        public static void PowerOff()
        {

            ManagementClass mc_os = new ManagementClass("Win32_OperatingSystem");
            mc_os.Scope.Options.EnablePrivileges = true;

            foreach (ManagementObject mo in mc_os.GetInstances())
            {
                mo.InvokeMethod("Shutdown", null, null);
            }

            mc_os.Dispose();
        }
...

PS. 必須加入參考 : 專案->加入參考->Systme.Management

資料來源 : http://www.dotblogs.com.tw/nobel12/archive/2009/10/05/10912.aspx