Page 1 of 1

Warning under 64 Bit MSVC but none unde BCC 32 Bit

PostPosted: Sun Apr 09, 2023 5:00 am
by Jimmy
hi,

i got a Warning when compile under 64 Bit using MSVC
HB_FUNC.PRG(1597): warning C4189: "pStr": Lokale Variable ist initialisiert aber nicht referenziert

'Local variable is initialized but not referenced'
'La variable local se inicializa pero no se hace referencia'
'La variable locale est initialisée mais non référencée'
'A variável local é inicializada, mas não referenciada'
'Lokale Variable ist initialisiert aber nicht referenziert'
'La variabile locale è inizializzata ma non referenziata'


Code: Select all  Expand view
HB_FUNC( FINDREPLACEDLGGETOPTIONS )
{
   #ifndef _WIN64
      LPARAM lParam = (LPARAM) hb_parnl (1);
   #else
      LPARAM lParam = (LPARAM) hb_parnll (1);
   #endif
   FINDREPLACE *FR = (FINDREPLACE *) lParam;
1596   LONG nRet = -1;
1597   LPSTR pStr;
1598
   if ( FR->Flags & FR_DIALOGTERM )
       nRet =  0;

   if ( FR->Flags & FR_FINDNEXT )
       nRet =  1;

   if ( FR->Flags & FR_REPLACE )
       nRet =  2;

   if ( FR->Flags & FR_REPLACEALL )
       nRet =  3;

   hb_reta (6);

   hb_storvnl ( (LONG) nRet,                       -1,  1 );

   #ifndef UNICODE
      hb_storvc (  FR->lpstrFindWhat,              -1,  2 );
      hb_storvc (  FR->lpstrReplaceWith,           -1,  3 );
   #else
1619      pStr = WideToAnsi( FR->lpstrFindWhat );
1620      hb_storvc (  pStr,                           -1,  2 );
1621      pStr = WideToAnsi( FR->lpstrReplaceWith );
1622      hb_storvc (  pStr,                           -1,  3 );
   #endif

   hb_storvl  ( (BOOL) (FR->Flags & FR_DOWN),      -1,  4 );
   hb_storvl  ( (BOOL) (FR->Flags & FR_MATCHCASE), -1,  5 );
   hb_storvl  ( (BOOL) (FR->Flags & FR_WHOLEWORD), -1,  6 );
}

how can i get rid of this Warning :?:

Re: Warning under 64 Bit MSVC but none unde BCC 32 Bit

PostPosted: Sun Apr 09, 2023 6:26 am
by Antonio Linares
Dear Jimmy,

Remove this line:
LPSTR pStr;

and place it here:
Code: Select all  Expand view
  #else
   {  // new
      LPSTR pStr = WideToAnsi( FR->lpstrFindWhat );  // modified
      hb_storvc (  pStr,                           -1,  2 );
      pStr = WideToAnsi( FR->lpstrReplaceWith );
      hb_storvc (  pStr,                           -1,  3 );
   }  // new
   #endif

Re: Warning under 64 Bit MSVC but none unde BCC 32 Bit

PostPosted: Sun Apr 09, 2023 6:49 am
by Jimmy
Antonio Linares wrote:Dear Jimmy,

Remove this line:
LPSTR pStr;

and place it here:
[code=fw]   #else

ah, understand
thx for Tip