warning #2228: Unable to expand function 'StringCbPrintfW' inline.

Started by Snowman, June 25, 2015, 11:20:14 PM

Previous topic - Next topic

Snowman

Hello forum. I am using Pelles C version 8.00.60.
I am compiling the code below with speed optimizations and Level 2 warnings.

#define UNICODE
#define _UNICODE

#include <windows.h>
#include <tchar.h>
#include <strsafe.h>

int _tmain(void)
{
    TCHAR test[200];

    (void)StringCbPrintf(test, sizeof test, _T("Hello Windows API!"));
    return 0;
}


The warning in this thread's title is given if I use StringCbPrintf() but not if I use _sntprintf():
main.c(14): warning #2228: Unable to expand function 'StringCbPrintfW' inline.

My questions are:

  • What can I do about this warning other than disable it?
  • Should I use _sntprintf() instead, just for the sake of being inlined?
  • Will this be fixed in future versions of Pelles C?

frankie

 

  • Do nothing. This warning is only informative that the compiler is unable to inline the function. The function StringCbPrintfW is declared __inline, that is a suggestion to compiler and not an imposition to inline it (like could be __forceinline).
  • _sntprintf is not implemented in PellesC. Using it you'll get only an error message suggesting you to use StringCbPrintf()
  • There is not so much to fix here. Maybe a better code generator in future versions will do it...
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

ElectroDoc

You can simply change the warning level to 1 and see if this will 'hide' that warning.

jj2007

Quote from: ElectroDoc on July 01, 2015, 02:56:32 AM
You can simply change the warning level to 1 and see if this will 'hide' that warning.

Better:
#pragma warn(disable:2228)
#include <strsafe.h>