Diagnostic 269: invalid format string conversion

Submit New Article

December 7, 2009 12:00 AM PST



Casue: 

This warning is triggered by a printf or scanf format specifier that is not appropriate for the type of the variable being printed.


Example: 

#include <stdio.h>

int main() {
   long int li = 0;
   printf("%l\n",li);     // %l is the size specifier; the type specifer is missing
   printf("%ld\n",li);  // OK
   return 0;
}

 

> icl -c /W4 diag269.cpp
Intel(R) C++ Compiler Professional for applications running on IA-32, Version 11.1    Build 20090511 Package ID: w_cproc_p_11.1.035
Copyright (C) 1985-2009 Intel Corporation.  All rights reserved.

diag269.cpp
diag269.cpp(5): warning #269: invalid format string conversion
printf("%l\n",li);
           ^ 



Resolution :

Use proper type specifier.




Do you need more help?


This article applies to: Intel® C++ Compiler for Linux* Knowledge Base,   Intel® C++ Compiler for Mac OS X* Knowledge Base,   Intel® C++ Compiler for Windows* Knowledge Base,   Intel® Parallel Composer Knowledge Base