NO

Author Topic: Semicolon Discrepancy  (Read 47 times)

Offline John Z

  • Member
  • *
  • Posts: 954
Semicolon Discrepancy
« on: Yesterday at 05:31:16 AM »
Here is an interesting thing -
Code: [Select]
BOOL SetToolbarImage(HWND hwnd,int button, int image)
{ BOOL RetVal = FALSE;

  //BookMark [{Bug?}]
  RetVal = ToolBar_ChangeBitmap(hwnd,button,image)
  ToolBar_AutoSize(hwnd);

 return RetVal;
}/* end settoolbarimage */

This compiles without error in Pelles C . . . notice the absence of the semicolon
------
Granted this define adds a semicolon - but is that still within the C guidelines?
#define ToolBar_ChangeBitmap(hwnd,idButton,iBitmap)  (BOOL)SNDMSG((hwnd),TB_CHANGEBITMAP,(WPARAM)(idButton),(LPARAM)(iBitmap));

John Z

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2189
Re: Semicolon Discrepancy
« Reply #1 on: Yesterday at 06:42:35 AM »
Even Clang don't give any warnings, so bug report was groundless void ?
« Last Edit: Yesterday at 08:16:22 AM by TimoVJL »
May the source be with you

Offline John Z

  • Member
  • *
  • Posts: 954
Re: Semicolon Discrepancy
« Reply #2 on: Yesterday at 07:31:32 AM »
Even Clang don't give any warnings, so bug report was groundless ?

Groundless? Well I suppose so if in fact it is not true that every valid C statement must end with a ;
I called it a discrepancy not a bug, since it has no actual impact, other than syntax.

John Z

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2189
Re: Semicolon Discrepancy
« Reply #3 on: Yesterday at 07:49:22 AM »
Many C compilers see code this way:
Code: [Select]
#line 4 "SetToolbarImage.c"


BOOL SetToolbarImage(HWND hwnd,int button, int image)
{ BOOL RetVal = 0;


 RetVal = (BOOL)SendMessageA((hwnd),(0x0400 +43),(WPARAM)(button),(LPARAM)(image));
 (void)SendMessageA((hwnd),(0x0400 +33),0,0);

 return RetVal;
}
If someone use -E or -P, see source after preprocessing.

msvc see it otherwise
Code: [Select]
SetToolbarImage.c(11): error C2146: syntax error: missing ';' before identifier 'ToolBar_AutoSize'
May the source be with you

Offline John Z

  • Member
  • *
  • Posts: 954
Re: Semicolon Discrepancy
« Reply #4 on: Yesterday at 08:54:07 AM »
Thanks,

It is a good day then - I’ve learned something new.

John Z