社区
Qt
帖子详情
error C2440: “=”: 无法从“va_list”转换为“const char [22]”
天地一扁舟
2012-10-25 01:17:50
error C2440: “=”: 无法从“va_list”转换为“const char [22]”
请问这个错误应该怎么改正
...全文
92
3
打赏
收藏
error C2440: “=”: 无法从“va_list”转换为“const char [22]”
error C2440: “=”: 无法从“va_list”转换为“const char [22]” 请问这个错误应该怎么改正
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
开发者说
2012-10-26
打赏
举报
回复
va_arg(arg, char *)
圆圆胖胖的车车
2012-10-26
打赏
举报
回复
贴代码吧。 可能是类型不匹配。
proorck6
2012-10-25
打赏
举报
回复
把源代码贴出来,va_list是什么,不知道。
C++实现mySQL接口
开源的My sql连接接口,用C++,OrzMySQL::OrzMySQL() : m_impl(new OrzMySQLImpl) { } OrzMySQL::~OrzMySQL() { if (m_impl) { delete m_impl; } } DBId OrzMySQL::getId()
const
{ return m_impl->getId(); } bool OrzMySQL::initialize(DBId _dbId,
const
Params
& _params) { return m_impl->initialize(_dbId, _params); } bool OrzMySQL::boost() { return m_impl->boost(); } void OrzMySQL::shutdown() { m_impl->shutdown(); } QRWrap OrzMySQL::query(
const
char
* _str, uint32 _len, ...) { QRWrap qrw; if (_str == 0) { sLogger->out(OL_
ERROR
, __FILE__, " - [", d2s(__LINE__).c_str(), "]: ", " _str == 0!", 0); return qrw; }
va
_
list
arg_ptr;
va
_start(arg_ptr, _len); DBQueryDataShrPtr dbq = allocDBQyd(); if (_len == 0) _len = strlen(_str); dbq->dbQstr.append(_str, _len); dbq->hasHdr = false; while (1) {
char
* str = 0; str =
va
_arg(arg_ptr,
char
*); if (!str) break; uint32 len = 0; len =
va
_arg(arg_ptr, uint32); if (len == 0) len = strlen(str); dbq->dbQstr.append(str, len); }
va
_end(arg_ptr); return m_impl->query(dbq); }
一个不错的地形编辑器源码.zip
/****************************************************************************************/ /* Compiler.cpp */ /* */ /* Author: Jim Mischel */ /* Description: Dialog and thread code for compiling maps with gbsplib */ /* */ /* The contents of this file are subject to the Genesis3D Public License */ /* Version 1.01 (the "License"); you may not use this file except in */ /* compliance with the License. You may obtain a copy of the License at */ /* http://www.genesis3d.com */ /* */ /* Software distributed under the License is distributed on an "AS IS" */ /* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */ /* the License for the specific language governing rights and limitations */ /* under the License. */ /* */ /* The Original Code is Genesis3D, released March 25, 1999. */ /* Copyright (C) 1996-1999 Eclipse Entertainment, L.L.C. All Rights Reserved */ /* */ /****************************************************************************************/ #include "stdafx.h" #include "compiler.h" #pragma warning(disable : 4201 4214 4115 4514 4711) #include
#include
#pragma warning(default : 4201 4214 4115) #include
#include
#include
#include "filepath.h" #include "consoletab.h" // for ConPrintf (yes, it's ugly) #include "util.h" static CWinThread *CompilerThread = NULL; static HWND hwndThreadParent = NULL; static geBoolean ThreadActive = GE_FALSE; static HINSTANCE GBSPHandle = NULL; static GBSP_FuncHook *GlobalFHook; static ofstream *CompileLog; Compiler
Error
Enum Compiler_RunPreview (
char
const
*PreviewFilename,
char
const
*MotionFilename,
char
const
*GPreviewPath ) { assert (ThreadActive == GE_FALSE);
char
DestBspName[_MAX_PATH]; { // Verify the .BSP file exists... if (_access (PreviewFilename, 0) != 0) { return COMPILER_
ERROR
_NOBSP; } } // we're going to copy the preview file to the "levels" subdirectory // of the GPreviewPath directory... // // So, if the PreviewFilename is "C:\MyStuff\MyLevel.bsp", // and GPreviewPath is "C:\Editor\GPreview.exe", then the resulting // file name is "C:\Editor\levels\MyLevel.bsp" // { /*
char
PreviewDrive[_MAX_PATH];
char
PreviewDir[_MAX_PATH];
char
Name[_MAX_PATH];
char
Ext[_MAX_PATH]; _splitpath (PreviewFilename, NULL, NULL, Name, Ext); _splitpath (GPreviewPath, PreviewDrive, PreviewDir, NULL, NULL); strcat (PreviewDir, "media\\levels\\"); _makepath (DestBspName, PreviewDrive, PreviewDir, Name, Ext); */ // make dest path same as source path strcpy(DestBspName, PreviewFilename); } // if source and destination are the same, then don't copy... if (stricmp (DestBspName, PreviewFilename) != 0) { if(!CopyFile (PreviewFilename, DestBspName, FALSE)) { int Last
Error
; Last
Error
= GetLast
Error
(); if (Last
Error
!=
ERROR
_FILE_EXISTS) { ConPrintf("GPreviewPath: %s \n", GPreviewPath); ConPrintf("CopyFile (%s, %s)\nGetLast
Error
()==%d\n", PreviewFilename, DestBspName, Last
Error
); return COMPILER_
ERROR
_BSPCOPY; } } } { // copy the motion file if it exists
char
DestName[_MAX_PATH]; // check to see if the file exists FilePath_SetExt (DestBspName, ".mot", DestName); if (_access (MotionFilename, 0) == 0) // _access returns 0 on success...of course! { if (stricmp (MotionFilename, DestName) != 0) { if (!CopyFile (MotionFilename, DestName, FALSE)) { if(GetLast
Error
() !=
ERROR
_FILE_EXISTS) { ConPrintf ("%s", "Unable to copy the motion file.\n"); ConPrintf ("%s", "Continuing with preview.\n"); } } } } else { _unlink (DestName); } } { SHELLEXECUTEINFO shx;
char
Params[_MAX_PATH];
char
DefaultDir[_MAX_PATH];
char
NoExtName[_MAX_PATH]; FilePath_GetDriveAndDir (GPreviewPath, DefaultDir); FilePath_GetName (DestBspName, NoExtName); sprintf (Params, "-map %s", NoExtName); shx.fMask = 0; shx.hwnd = NULL; //(HWND)AfxGetMainWnd(); shx.lpVerb = NULL; shx.lpFile = GPreviewPath; shx.lpParameters= Params; shx.lpDirectory = DefaultDir; shx.nShow = SW_NORMAL; shx.hInstApp = NULL; shx.cbSize = sizeof(shx); ShellExecuteEx(&shx;); } return COMPILER_
ERROR
_NONE; } geBoolean Compiler_CancelCompile ( void ) { if (!ThreadActive) { return GE_FALSE; } return GlobalFHook->GBSP_Cancel (); } static Compiler
Error
Enum Compiler_LoadCompilerDLL ( GBSP_FuncHook **ppFHook, HINSTANCE *pHandle,
ERROR
_CB
Error
CallbackFcn, PRINTF_CB PrintfCallbackFcn ) { GBSP_INIT *GBSP_Init; GBSP_Hook Hook; GBSP_FuncHook *FHook; assert (ppFHook != NULL); assert (pHandle != NULL); *ppFHook = NULL; Hook.
Error
=
Error
CallbackFcn; Hook.Printf = PrintfCallbackFcn; GBSPHandle = LoadLibrary("gbsplib.dll"); if (GBSPHandle == NULL) { PrintfCallbackFcn ("Compile Failed: Unable to load gbsplib.dll!\nGetLast
Error
returned %d.\n", GetLast
Error
()); return COMPILER_
ERROR
_NODLL; } GBSP_Init =(GBSP_INIT*)GetProcAddress(GBSPHandle, "GBSP_Init"); if (GBSP_Init == NULL) { PrintfCallbackFcn ("%s", "Compile Failed: Couldn't initialize GBSP_Init, GBSPLib.Dll.\n."); FreeLibrary(GBSPHandle); return COMPILER_
ERROR
_MISSINGFUNC; } FHook = GBSP_Init (&Hook;); if (FHook == NULL) { PrintfCallbackFcn ("%s", "Compile Failed: GBSP_Init returned NULL Hook!, GBSPLib.Dll.\n."); FreeLibrary(GBSPHandle); return COMPILER_
ERROR
_MISSINGFUNC; } if(FHook->VersionMajor > GBSP_VERSION_MAJOR) { PrintfCallbackFcn ("%s", "Compile Failed: GBSP Version Incompatible, GBSPLib.Dll.\n."); FreeLibrary (GBSPHandle); return COMPILER_
ERROR
_MISSINGFUNC; } *ppFHook = FHook; *pHandle = GBSPHandle; return COMPILER_
ERROR
_NONE; } Compiler
Error
Enum Compiler_Compile ( CompileParamsType
const
*pParams,
ERROR
_CB
Error
CallbackFcn, PRINTF_CB PrintfCallbackFcn ) { HINSTANCE GBSPHandle; Compiler
Error
Enum CompileRslt; GBSP_RET
VA
L GbspRslt;
char
BspFilename[_MAX_PATH];
char
MotionFilename[_MAX_PATH]; // load compiler DLL CompileRslt = Compiler_LoadCompilerDLL (&GlobalFHook;, &GBSPHandle;,
Error
CallbackFcn, PrintfCallbackFcn); if (CompileRslt == COMPILER_
ERROR
_NONE) { FilePath_SetExt (pParams->Filename, ".bsp", BspFilename); FilePath_SetExt (pParams->Filename, ".mot", MotionFilename); if (pParams->EntitiesOnly) { #if 1 #pragma message ("Should UpdateEntities return a GBSP_RET
VA
L?") if (GlobalFHook->GBSP_UpdateEntities ((
char
*)pParams->Filename, BspFilename)) { GbspRslt = GBSP_OK; } else { GbspRslt = GBSP_
ERROR
; } #else GbspRslt = GlobalFHook->GBSP_UpdateEntities ((
char
*)pParams->Filename, BspFilename); #endif switch (GbspRslt) { case GBSP_
ERROR
: PrintfCallbackFcn ("%s", "Compile Failed: GBSP_UpdateEntities returned an
error
. GBSPLib.Dll.\n"); CompileRslt = COMPILER_
ERROR
_BSPFAIL; break; case GBSP_OK : break; case GBSP_CANCEL : PrintfCallbackFcn ("%s", "UpdateEntities cancelled by user.\n"); CompileRslt = COMPILER_
ERROR
_USERCANCEL; break; default : assert (0); } } else if (pParams->RunBsp) { _unlink (MotionFilename); // gotta make sure this doesn't exist... GbspRslt = GlobalFHook->GBSP_CreateBSP ((
char
*)pParams->Filename, (BspParms *)&pParams;->Bsp); switch (GbspRslt) { case GBSP_
ERROR
: PrintfCallbackFcn ("%s", "Compile Failed: GBSP_CreateBSP encountered an
error
, GBSPLib.Dll.\n."); CompileRslt = COMPILER_
ERROR
_BSPFAIL; break; case GBSP_OK : //save as a bsp GbspRslt = GlobalFHook->GBSP_SaveGBSPFile(BspFilename); switch (GbspRslt) { case GBSP_
ERROR
: PrintfCallbackFcn ("Compile Failed: GBSP_SaveGBSPFile for file: %s, GBSPLib.Dll.\n.", BspFilename); CompileRslt = COMPILER_
ERROR
_BSPSAVE; break; case GBSP_CANCEL : PrintfCallbackFcn ("%s", "Save cancelled by user\n"); CompileRslt = COMPILER_
ERROR
_USERCANCEL; break; case GBSP_OK : break; default : assert (0); } break; case GBSP_CANCEL : PrintfCallbackFcn ("%s", "Compile cancelled by user\n"); CompileRslt = COMPILER_
ERROR
_USERCANCEL; break; default : assert (0); //?? } GlobalFHook->GBSP_FreeBSP(); } } if (CompileRslt == COMPILER_
ERROR
_NONE) { if(pParams->DoVis && !pParams->EntitiesOnly) { GbspRslt = GlobalFHook->GBSP_VisGBSPFile ((
char
*)BspFilename, (VisParms *)&pParams;->Vis); switch (GbspRslt) { case GBSP_
ERROR
: PrintfCallbackFcn ("Warning: GBSP_VisGBSPFile failed for file: %s, GBSPLib.Dll.\n.", BspFilename); break; case GBSP_CANCEL : PrintfCallbackFcn ("%s", "GBSP_VisGBPSFile cancelled by user\n"); CompileRslt = COMPILER_
ERROR
_USERCANCEL; break; case GBSP_OK : break; default : assert (0); } } } if (CompileRslt == COMPILER_
ERROR
_NONE) { if (pParams->DoLight) { /* The compiler has no flag that tells it not to do min lighting. So, if the min lighting flag is not on, we set the MinLight vector to all 0s. */ LightParms rad; rad = pParams->Light; if (!pParams->UseMinLight) { geVec3d_Set (&rad;.MinLight, 0.0f, 0.0f, 0.0f); } // If UseMinLight isn't on, then don't pass GbspRslt = GlobalFHook->GBSP_LightGBSPFile(BspFilename, &rad;); switch (GbspRslt) { case GBSP_
ERROR
: PrintfCallbackFcn ("Warning: GBSP_LightGBSPFile failed for file: %s, GBSPLib.Dll.\n", BspFilename); break; case GBSP_CANCEL : PrintfCallbackFcn ("%s", "GBSP_LightGBSPFile cancelled by user\n"); CompileRslt = COMPILER_
ERROR
_USERCANCEL; break; case GBSP_OK : break; default : assert (0); } } } // and free the DLL... if (GBSPHandle != NULL) { FreeLibrary (GBSPHandle); } return CompileRslt; } static void Compiler_NotifyApp (
char
const
*buf, int MsgId ) { #if 1
char
*errmsg; errmsg = Util_Strdup (buf); if (errmsg != NULL) { ::PostMessage (hwndThreadParent, MsgId, COMPILER_PROCESSID, (LPARAM)errmsg); } #else ConPrintf ("%s", buf); #endif } static void Compiler_PrintfCallback (
char
*format, ... ) {
va
_
list
argptr;
char
buf[32768]; //this is ... cautious
va
_start (argptr, format); vsprintf (buf, format, argptr);
va
_end (argptr); if (CompileLog) (*CompileLog) << buf; Compiler_NotifyApp (buf, WM_USER_COMPILE_MSG); } static void Compiler_
Error
Callback (
char
*format, ... ) {
va
_
list
argptr;
char
buf[32768]; //this is ... cautious
va
_start (argptr, format); vsprintf (buf, format, argptr);
va
_end (argptr); if (CompileLog) (*CompileLog) << buf; Compiler_NotifyApp (buf, WM_USER_COMPILE_ERR); } static UINT Compiler_ThreadProc ( void *pParam ) { CompileParamsType CompileParams; Compiler
Error
Enum CompileRslt; assert (pParam != NULL); assert (ThreadActive == GE_FALSE); ThreadActive = GE_TRUE; CompileParams = *((CompileParamsType *)pParam);
char
LogFilename[_MAX_PATH]; FilePath_SetExt(CompileParams.Filename, ".log", LogFilename); CompileLog = new ofstream(LogFilename, ofstream::out | ofstream::trunc); CompileRslt = Compiler_Compile (&CompileParams;, Compiler_
Error
Callback, Compiler_PrintfCallback); if (CompileRslt == COMPILER_
ERROR
_NONE) { Compiler_PrintfCallback ("%s", "------------------------------\n"); Compiler_PrintfCallback ("%s", "Compile successfully completed\n"); } if (CompileLog) { (*CompileLog).close(); delete CompileLog; } // notify parent that the compile has completed ::PostMessage (hwndThreadParent, WM_USER_COMPILE_DONE, COMPILER_PROCESSID, (LPARAM)CompileRslt); ThreadActive = GE_FALSE; return 0; } Compiler
Error
Enum Compiler_StartThreadedCompile ( CompileParamsType
const
*pParams, HWND hwndNotify ) { CWinThread *Thread; assert (ThreadActive == GE_FALSE); hwndThreadParent = hwndNotify; Thread = AfxBeginThread ( Compiler_ThreadProc, // AFX_THREADPROC pfnThreadProc, (LPVOID)pParams, // LPVOID pParam, THREAD_PRIORITY_NORMAL, // int nPriority = THREAD_PRIORITY_NORMAL, 0, // UINT nStackSize = 0, 0, // DWORD dwCreateFlags = 0, NULL // LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL ); if (Thread != NULL) { CompilerThread = Thread; return COMPILER_
ERROR
_NONE; } else { return COMPILER_
ERROR
_THREAD; // couldn't spawn the thread } } geBoolean Compiler_CompileInProgress ( void ) { return ThreadActive; }
YOLOv5目标检测实战:Jetson Nano部署
PyTorch版的YOLOv5是高性能的实时目标检测方法。Jetson Nano是英伟达含有GPU的人工智能硬件。本课程讲述如何部署YOLOv5在Jetson Nano开发板上。部署完成后可进行图像、视频文件和摄像头视频的实时目标检测。...
ffmpeg编译的android可用的so文件,多个版本
经过本人测试,可以调用并成功执行ffmpeg的命令 jni相关的c语言代码为 #include #include #include #ifdef ANDROID #include #include #define LOGE(format, ...) __android_log_print(ANDROID_LOG_
ERROR
, "(>__<) " format "\n", ##__
VA
_ARGS__) #define LOGI(format, ...) LOGE("(^_^) " format "\n", ##__
VA
_ARGS__) #endif int ffmpegmain(int argc,
char
**argv); //Output FFmpeg's av_log() void custom_log(void *ptr, int level,
const
char
* fmt,
va
_
list
vl){ //To TXT file FILE *fp=fopen("/storage/emulated/0/av_log.txt","a+"); if(fp){ vfprintf(fp,fmt,vl); fflush(fp); fclose(fp); } //To Logcat //LOGE(fmt, vl); } JNIEXPORT jint JNICALL Ja
va
_com_rinogame_ffmpegandroidtranscoder_MainActivity_ffmpegcore( JNIEnv * env, jobject thiz, jint cmdnum, jobjectArray cmdline) { //FFmpeg av_log() callback av_log_set_callback(custom_log); int argc=cmdnum;
char
** argv=(
char
**)malloc(sizeof(
char
*)*argc); int i=0; for(i=0;iGetObjectArrayElement(env,cmdline,i);
const
char
* tmp=(*env)->GetStringUTF
Char
s(env,string,0); argv[i]=(
char
*)malloc(sizeof(
char
)*1024); strcpy(argv[i],tmp); } ffmpegmain(argc,argv); for(i=0;i
string转
Char
*(
error
C2440
: '=' : cannot convert from '
const
char
*' to '
char
*')
今天遇到一个问题string转
char
*总是失败提示错误为
error
C2440
: '=' : cannot convert from '
const
char
*' to '
char
*' 源代码为: string temFile;
char
* filenamecpy; filenamecpy = temFile.data(); 解决方法 filenamecpy =
Qt
16,215
社区成员
26,594
社区内容
发帖
与我相关
我的任务
Qt
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
复制链接
扫一扫
分享
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章