Compiler fails on resolving {IF DEFINDED... but Code tools handles it ok.? lazarus / 31-LCL ---------------------------------------------------------------------- jamie · 2020-05-09 11:38 Found in the "ComboEx.inc" file... at the DrawItem event... {IF DEFINED(LCLWin32) or DEFINDED(LCLWin64)}  do something {$ELSE}  do nothing {$ENDIF} Code tools always resolves it correctly... it finds the first one.. compiler never finds it.. it always goes to the do nothing.. Now in a simple test app it always works. but the only difference here is the test is being done in UNIT1 where as in the failing case it is in a INC file..  I don't know if this has any bearing on the case but it does fail.  Proof of this is the current existing TComboBoxEx that is installed in the Misc tab the Edit part is suppose to be all blue highlighted in the background when an item is selected. it is not because that test is failing at compile time...  you can drop that control on the form and see for your self the background is not painted button blue face like the code is stated for …. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   {$IF DEFINED(LCLWin32) or DEFINED(LCLWin64)}  aFocusedEditableMainItemNoDD := (Focused and aMainItem and not aDropped); << code tools finds this with no problem  {$ELSE}  aFocusedEditableMainItemNoDD := False; <<< fpc always picks this one however!   {$ENDIF} ---------------------------------------------------------------------- Thaddy · 2020-05-09 12:13 Quote from: jamie on May 09, 2020, 01:38:57 pmFound in the "ComboEx.inc" file... at the DrawItem event... {IF DEFINED(LCLWin32) or DEFINDED(LCLWin64)}  do something {$ELSE}  do nothing {$ENDIF} Code tools always resolves it correctly... it finds the first one.. compiler never finds it.. it always goes to the do nothing.. Now in a simple test app it always works. but the only difference here is the test is being done in UNIT1 where as in the failing case it is in a INC file..  I don't know if this has any bearing on the case but it does fail.  Proof of this is the current existing TComboBoxEx that is installed in the Misc tab the Edit part is suppose to be all blue highlighted in the background when an item is selected. it is not because that test is failing at compile time...  you can drop that control on the form and see for your self the background is not painted button blue face like the code is stated for …. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   {$IF DEFINED(LCLWin32) or DEFINED(LCLWin64)}  aFocusedEditableMainItemNoDD := (Focused and aMainItem and not aDropped); << code tools finds this with no problem  {$ELSE}  aFocusedEditableMainItemNoDD := False; <<< fpc always picks this one however!   {$ENDIF}  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // you mean?:{$IF DEFINED(LCLWin32) or DEFINED(LCLWin64)} ---------------------------------------------------------------------- jamie · 2020-05-09 16:20 yes Taddy, that is of course what I am talking about.. Code tools detects this while having the INC file open but when compiling the compiler does not and takes the alternate to the statement.  if you test that in a simple do nothing app it works. so the only scenario I can come up with at the moment is that it's in a INC file.   Unless there is some magic smoke somewhere that is undefining it at compile time, if that being the case them maybe they should put the magic smoke back in ? ---------------------------------------------------------------------- PascalDragon · 2020-05-09 20:22 It seems that for some reason the IDE defines the correct define for the widgetset (thus CodeTools handles it correctly), but does not pass that along to the compiler when compiling the LCL package. Best report a bug. ---------------------------------------------------------------------- jamie · 2020-05-09 20:55 Ok, thanks, I'll post a bug report and point here. ---------------------------------------------------------------------- jamie · 2020-05-10 18:44 Apparently there is an issue with building the LCL base and related files because currently while working on a control, making changes requires the base to get recompiled and thus these defines are not seen via the compiler..  Also, this state is current even in the official releases. This seems to go back a bit because I checked older versions of Lazarus down to 2.0.4. I don't have anything older now, and the issue is also there, too.  I really don't believe this one control I am currently working on could be the only one getting disrupted.  Have a good day.. ---------------------------------------------------------------------- tetrastes · 2020-05-10 20:40 The file lcl\comboex.pas which includes comboex.inc is absolutely correctly compiled without defining LCLwin32, because this file is common for all widgetsets. It must not contain this define, it is obvious error. Moreover, this is the only file in lcl\ directory, which has this define. And at last, there is no widgetset "win64", for x86_64-win64 target still -dLCLwin32 is used, so this is one more question to the author and acceptor(s) of comboex.pas. ---------------------------------------------------------------------- jamie · 2020-05-11 00:45 You seem to be mistaken, there is  a LCLWin32 define.. the LCLWin64 was most likely put there for a safety catch..  Code tools does see it as a valid define and it does quite well in finding identifiers.  You need to actually look at the code to see what I am talking about, place a break point on it.. it fails. The compiler isn't able to find the define but its there in the files cause code tools finds it just dandy..  Compiler always takes the alternate path.   I've seen that defined used before although not common to detect the widget...  For a windows target that INC file is not compiled correctly..  For other targets its fine because that is the intent of those check points which is to exclude the code that follows ..  Those defines work just fine if you build an app, a normal app where you aren't compiling the LCLbase, which is where it falls apart. It seems like those defines aren't known at that time.  It's most likely the build script for the LCLBase and LCL files in general. For the time being I have replaced those defines with a "WINDOWS" since those are the widgets I assume to be using so we'll go with that for now..  Have a good day.. ---------------------------------------------------------------------- tetrastes · 2020-05-11 11:41 I am not mistaken. There is LCLwin32 define in conboex.inc, but it must not be there, this is bug, and code under this define is not compiled, and should not. And again, there are NO other files with this define in lcl\ dir (LCLBase package). You confuse with compiling for specific target and for specific widgetset. The files of LCLBase package are common for ALL widgetsets for given target. The source files for specific widgetsets are in lcl\interfaces (LCL package), and even there there are no files with LCLwin32, or for example  LCLqt5 define. Compile, for example, app for x86_64-win64 target and qt5 widgetset. New folder "qt5" (with files compiled from sources in lcl\interfaces\qt5) appears in \lcl\units\x86_64-win64 dir, near the folder "win32". But other files in \lcl\units\x86_64-win64 dir (from LCLBase package), including comboex.o and comboex.ppu, are not recompiled. They are used unchanged for both qt5 and win32 widgetsets, and so compiled without any LCLWidgetType define. And that is why "Compiler always takes the alternate path". You can change in comboex.inc Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$IF DEFINED(LCLWin32) or DEFINED(LCLWin64)} to Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$IF DEFINED(MSWINDOWS)} and your code will be compiled for windows targets, but it will be used for ALL widgetsets at these targets. And that is the way LCLBase is intended for. If you want to write code for specific widgetset, you have to know better the structure and logic of LCL. You may begin with \lcl\widgetset\README.txt. ---------------------------------------------------------------------- Thaddy · 2020-05-11 12:42 Lazarus has its own sets of defines. So if your program does not need Lazarus LCL, these defines are not recognized. Maybe that is the issue. In such case, define them by hand or simply do not refer to them. ---------------------------------------------------------------------- jamie · 2020-05-11 19:49 Quote from: Thaddy on May 11, 2020, 02:42:43 pmLazarus has its own sets of defines. So if your program does not need Lazarus LCL, these defines are not recognized. Maybe that is the issue. In such case, define them by hand or simply do not refer to them. I guess u must the point. This problem is in at least 1 set of controls that are installed by default in lazarus this way and the code is compiled wrong. This isn't my code but I am making headway on making it a useable control set. ---------------------------------------------------------------------- tetrastes · 2020-05-11 20:04 Quote from: jamie on May 11, 2020, 09:49:24 pmQuote from: Thaddy on May 11, 2020, 02:42:43 pmLazarus has its own sets of defines. So if your program does not need Lazarus LCL, these defines are not recognized. Maybe that is the issue. In such case, define them by hand or simply do not refer to them. I guess u must the point. This problem is in at least 1 set of controls that are installed by default in lazarus this way and the code is compiled wrong. This isn't my code but I am making headway on making it a useable control set. I see that you hasn't read my post. You may stay with your opinion, but don't confuse others. The code is not compiled wrong, there is wrong code in comboex.inc. And I think you will not be able to make "it a useable control set" until you realize this. ---------------------------------------------------------------------- Thaddy · 2020-05-11 20:10 Then why? codetools is not the compiler. The compiler is right by definition ---------------------------------------------------------------------- tetrastes · 2020-05-11 20:20 Quote from: Thaddy on May 11, 2020, 10:10:38 pmThen why? codetools is not the compiler. The compiler is right by definition Fully agree. Thus jamie has to find and correct errors in code, but not in compile options for LCLBase.