码迷,mamicode.com
首页 > 其他好文 > 详细

nmake编译生成目标文件后还有error信息

时间:2015-08-11 13:55:34      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:

网是开源的c/c++日志库也不少,但用起来总觉得不方便,于是动手写了一个C++日志框架Log4K。

测试代码:

#include "log4k.h"

#pragma comment(lib, "log4k.lib")

static int g_Cnt = 0;
void LogTestThread1(LPVOID lpPara)
{
    DEBUG_FUNCTION();

    LOGFMTT(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTD(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTI(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTW(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTE(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);

    for (int i = 0; i < 10;)
    {
        LOGFMTT(L"[%d] %s", i++, __FUNCTIONW__);
        //Sleep(10);
    }
}

void LogTestThread2(LPVOID lpPara)
{
    DEBUG_FUNCTION();

    LOGFMTT_A("----------Function:%s, Line:%d", __FUNCTION__, __LINE__);
    LOGFMTD(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTI_A("----------Function:%s, Line:%d", __FUNCTION__, __LINE__);
    LOGFMTW(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTE_A("----------Function:%s, Line:%d", __FUNCTION__, __LINE__);

    for (int i = 0; i < 10;)
    {
        LOGFMTI(L"[%d] %s", i++, __FUNCTIONW__);
        //Sleep(10);
    }
}

int main()
{
    DEBUG_FUNCTION();

    LOG4K_SET_OUT(Kevin55::OUT_TO_STDOUT_AND_LOG);
    LOGFMTT(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTD(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTI(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTW(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTE(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);

    LOGFMTT_A("----------Function:%s, Line:%d", __FUNCTION__, __LINE__);
    LOGFMTD_A("----------Function:%s, Line:%d", __FUNCTION__, __LINE__);
    LOGFMTI_A("----------Function:%s, Line:%d", __FUNCTION__, __LINE__);
    LOGFMTW_A("----------Function:%s, Line:%d", __FUNCTION__, __LINE__);
    LOGFMTE_A("----------Function:%s, Line:%d", __FUNCTION__, __LINE__);

    HANDLE hThread[2];
    ZeroMemory(hThread, sizeof(HANDLE) * 2);

    hThread[0] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)LogTestThread1, NULL, 0, NULL);
    hThread[1] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)LogTestThread2, NULL, 0, NULL);


    for (int i = 0; i < 100; i++)
    {
        LOGFMTD(L"[%d]======%s", i, __FUNCTIONW__);
    }

    WaitForMultipleObjects(2, hThread, true, INFINITE);
    //LOG4K_SET_OUT(OUT_TO_STDOUT);

    LOGFMTT(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTD(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTI(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTW(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);
    LOGFMTE(L"----------Function:%s, Line:%d", __FUNCTIONW__, __LINE__);

    return 0;
}

技术分享

 

使用nmake编译及链接完成后,还有error信息,下面是所有nmake输出:

    cl /c /Zi /W3 /WX- /sdl /O2 /Oi /Oy- /GL /D WIN32 /D NDEBUG /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope   /FoD:\code\CPP_Code\KernalMainApp\Log4Z\Log4Z\out\Log4K.obj /FdD:\code\CPP_Code\KernalMainApp\Log4Z\Log4Z\out\vc120.pdb /Gd /TP /analyze- /errorReport:prompt D:\code\CPP_Code\KernalMainApp\Log4Z\Log4Z\Log4K.cpp
Log4K.cpp
    link /ERRORREPORT:PROMPT /OUT:D:\code\CPP_Code\KernalMainApp\Log4Z\Log4Z\out\Log4K.exe /INCREMENTAL /NOLOGO /LIBPATH:"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib";"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /DEBUG /PDB:D:\code\CPP_Code\KernalMainApp\Log4Z\Log4Z\out\Log4K.pdp /LTCG /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /IMPLIB:D:\code\CPP_Code\KernalMainApp\Log4Z\Log4Z\out\Log4Z.lib /MACHINE:X86 D:\code\CPP_Code\KernalMainApp\Log4Z\Log4Z\out\log4k.obj
LINK : warning LNK4075: ignoring ‘/INCREMENTAL‘ due to ‘/LTCG‘ specification
Generating code
Finished generating code
    cl  Log4K.cpp
Log4K.cpp
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xlocale(337) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
Log4K.cpp(427) : error C2664: ‘BOOL SetConsoleTitleA(LPCSTR)‘ : cannot convert argument 1 from ‘const wchar_t [14]‘ to ‘LPCSTR‘
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Log4K.cpp(513) : error C2664: ‘DWORD GetModuleFileNameA(HMODULE,LPSTR,DWORD)‘ : cannot convert argument 2 from ‘wchar_t [128]‘ to ‘LPSTR‘
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

网上好像有人提交过类似的问题:https://connect.microsoft.com/VisualStudio/feedback/details/808657/vs2013-compiler-fails-on-function-templates-with-c-11-alternate-declaration-syntax,这个问题可能是编译器的一个bug。
 

 

nmake编译生成目标文件后还有error信息

标签:

原文地址:http://www.cnblogs.com/kernel0815/p/4720690.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!