2012-01-26 36 views
0

I実行されているコードの解析を無視し、私はC6269警告これらのライン警告C6269:操作の可能性不適切な順序:間接参照は、上のC++コードに

va_arg(argList, TCHAR_ARG); 
va_arg(argList, int*); 

上のエラーを取得しています 2010対:操作の可能性不適切な順序:間接参照は無視されました

これらの2行で警告が表示される理由は何ですか?

私は

case 'C': 
case 'C'|_atltmpFORCE_ANSI: 
case 'C'|_atltmpFORCE_UNICODE: 
case 'o'; 
case 'p': 
case 'n': 

完全なコード

inline void CXString::FormatV(LPCTSTR lpszFormat, va_list argList) 
{ 
    va_list argListSave = argList; 

    // make a guess at the maximum length of the resulting string 
    int nMaxLen = 0; 
    for (LPCTSTR lpsz = lpszFormat; *lpsz != '\0'; lpsz = CharNext(lpsz)) 
    { 
     // handle '%' character, but watch out for '%%' 
     if (*lpsz != '%' || *(lpsz = CharNext(lpsz)) == '%') 
     { 
      nMaxLen += (int)_tclen(lpsz); 
      continue; 
     } 

     int nItemLen = 0; 

     // handle '%' character with format 
     int nWidth = 0; 
     for (; *lpsz != '\0'; lpsz = CharNext(lpsz)) 
     { 
      // check for valid flags 
      if (*lpsz == '#') 
       nMaxLen += 2; // for '0x' 
      else if (*lpsz == '*') 
       nWidth = va_arg(argList, int); 
      else if (*lpsz == '-' || *lpsz == '+' || *lpsz == '0' || 
       *lpsz == ' ') 
       ; 
      else // hit non-flag character 
       break; 
     } 
     // get width and skip it 
     if (nWidth == 0) 
     { 
      // width indicated by 
      nWidth = _ttoi(lpsz); 
      for (; *lpsz != '\0' && _istdigit(*lpsz); lpsz = CharNext(lpsz)) 
       ; 
     } 

     int nPrecision = 0; 
     if (*lpsz == '.') 
     { 
      // skip past '.' separator (width.precision) 
      lpsz = CharNext(lpsz); 

      // get precision and skip it 
      if (*lpsz == '*') 
      { 
       nPrecision = va_arg(argList, int); 
       lpsz = CharNext(lpsz); 
      } 
      else 
      { 
       nPrecision = _ttoi(lpsz); 
       for (; *lpsz != '\0' && _istdigit(*lpsz); lpsz = CharNext(lpsz)) 
        ; 
      } 
     } 

     // should be on type modifier or specifier 
     int nModifier = 0; 
     switch (*lpsz) 
     { 
     // modifiers that affect size 
     case 'h': 
      nModifier = _atltmpFORCE_ANSI; 
      lpsz = CharNext(lpsz); 
      break; 
     case 'l': 
      nModifier = _atltmpFORCE_UNICODE; 
      lpsz = CharNext(lpsz); 
      break; 

     // modifiers that do not affect size 
     case 'F': 
     case 'N': 
     case 'L': 
      lpsz = CharNext(lpsz); 
      break; 
     } 

     // now should be on specifier 
     switch (*lpsz | nModifier) 
     { 
     // single characters 
     case 'c': 
     case 'C': 
      nItemLen = 2; 
      va_arg(argList, TCHAR_ARG); 
      break; 
     case 'c'|_atltmpFORCE_ANSI: 
     case 'C'|_atltmpFORCE_ANSI: 
      nItemLen = 2; 
      va_arg(argList, CHAR_ARG); 
      break; 
     case 'c'|_atltmpFORCE_UNICODE: 
     case 'C'|_atltmpFORCE_UNICODE: 
      nItemLen = 2; 
      va_arg(argList, WCHAR_ARG); 
      break; 

     // strings 
     case 's': 
     { 
      LPCTSTR pstrNextArg = va_arg(argList, LPCTSTR); 
      if (pstrNextArg == NULL) 
       nItemLen = 6; // "(null)" 
      else 
      { 
       nItemLen = lstrlen(pstrNextArg); 
       nItemLen = max(1, nItemLen); 
      } 
      break; 
     } 

     case 'S': 
     { 
#ifndef _UNICODE 
      LPWSTR pstrNextArg = va_arg(argList, LPWSTR); 
      if (pstrNextArg == NULL) 
       nItemLen = 6; // "(null)" 
      else 
      { 
       nItemLen = (int)wcslen(pstrNextArg); 
       nItemLen = max(1, nItemLen); 
      } 
#else 
      LPCSTR pstrNextArg = va_arg(argList, LPCSTR); 
      if (pstrNextArg == NULL) 
       nItemLen = 6; // "(null)" 
      else 
      { 
       nItemLen = lstrlenA(pstrNextArg); 
       nItemLen = max(1, nItemLen); 
      } 
#endif 
      break; 
     } 

     case 's'|_atltmpFORCE_ANSI: 
     case 'S'|_atltmpFORCE_ANSI: 
     { 
      LPCSTR pstrNextArg = va_arg(argList, LPCSTR); 
      if (pstrNextArg == NULL) 
       nItemLen = 6; // "(null)" 
      else 
      { 
       nItemLen = lstrlenA(pstrNextArg); 
       nItemLen = max(1, nItemLen); 
      } 
      break; 
     } 

     case 's'|_atltmpFORCE_UNICODE: 
     case 'S'|_atltmpFORCE_UNICODE: 
     { 
      LPWSTR pstrNextArg = va_arg(argList, LPWSTR); 
      if (pstrNextArg == NULL) 
       nItemLen = 6; // "(null)" 
      else 
      { 
       nItemLen = (int)wcslen(pstrNextArg); 
       nItemLen = max(1, nItemLen); 
      } 
      break; 
     } 
     } 

     // adjust nItemLen for strings 
     if (nItemLen != 0) 
     { 
      nItemLen = max(nItemLen, nWidth); 
      if (nPrecision != 0) 
       nItemLen = min(nItemLen, nPrecision); 
     } 
     else 
     { 
      switch (*lpsz) 
      { 
      // integers 
      case 'd': 
      case 'i': 
      case 'u': 
      case 'x': 
      case 'X': 
      case 'o': 
       va_arg(argList, int); 
       nItemLen = 32; 
       nItemLen = max(nItemLen, nWidth+nPrecision); 
       break; 

      case 'e': 
      case 'f': 
      case 'g': 
      case 'G': 
#ifndef _DEBUG 
       ::OutputDebugString(_T("Floating point (%%e, %%f, %%g, and %%G) is not supported by the WTL::CXString class.")); 
       ::DebugBreak(); 
#endif //!_DEBUG 
       break; 

      case 'p': 
       va_arg(argList, void*); 
       nItemLen = 32; 
       nItemLen = max(nItemLen, nWidth+nPrecision); 
       break; 

      // no output 
      case 'n': 
       va_arg(argList, int*); 
       break; 

      default: 
       break; 
      }; 
     } 

     // adjust nMaxLen for output nItemLen 
     nMaxLen += nItemLen; 
    } 

    GetBuffer(nMaxLen); 
    int nRet = _vstprintf_s(m_pchData, GetAllocLength(), lpszFormat, argListSave); 
    nRet; // ref 
    ReleaseBuffer(); 

    va_end(argListSave); 
} 
+0

他に何をしていますか?もっとコードを表示できますか? – templatetypedef

+0

@templatetypedef質問を更新しました –

+0

「va_arg」の結果を使用するか、警告を抑制または無視してください。 –

答えて

5

コンパイラあなたは戻り値を使用していないので、が混乱しを取得することができるスイッチの場合にエラーを取得しています。試しましたか?

TCHAR_ARG arg1 = va_arg(argList, TCHAR_ARG); 
int* arg2 = va_arg(argList, int*); 
+1

これはまさに問題の原因です。 –

関連する問題