"Note: passing compiler option -M twice with different values" lazarus / 11-Options ---------------------------------------------------------------------- creaothceann · 2019-04-07 17:34 In Lazarus I'm setting the syntax mode (menu | Project | Project Options | Compiler Options | Parsing | Syntax mode) to Free Pascal ("-Mfpc"). In the "Custom Options" I set these: -CfAVX2 -CpCOREAVX2 -Madvancedrecords -Mdefaultparameters -Mout -Mresult The result is that my project compiles successfully, but in the messages window I get the hint "Note: passing compiler option -M twice with different values". Do I just disable that hint (somehow)? ---------------------------------------------------------------------- Thausand · 2019-04-07 17:42 Quote from: creaothceann on April 07, 2019, 07:34:47 pmIn the "Custom Options" I set these: -CfAVX2 -CpCOREAVX2 -Madvancedrecords -Mdefaultparameters -Mout -Mresult The result is that my project compiles successfully, but in the messages window I get the hint "Note: passing compiler option -M twice with different values". Do I just disable that hint (somehow)? Not must disable !!! you make error. -M only for language mode. No for mode switch. add: option command line -M write help here https://www.freepascal.org/docs-html/user/userap1.html Code: [Select]-M  Set language mode to         -Mfpc      Free Pascal dialect (default)        -Mobjfpc   FPC mode with Object Pascal support        -Mdelphi   Delphi 7 compatibility mode        -Mtp       TP/BP 7.0 compatibility mode        -Mmacpas   Macintosh Pascal dialects compatibility mode        -Miso      ISO 7185 mode        -Mextendedpascal ISO 10206 mode        -Mdelphiunicode Delphi 2009 and later compatibility mode $MODESWITCH write help here https://www.freepascal.org/docs- html/prog/progsu105.html#x113-1140001.3.22 Code: [Select]{$MODESWITCH XXX}  {$MODESWITCH XXX+}  {$MODESWITCH XXX-} can make in program source or unit ---------------------------------------------------------------------- creaothceann · 2019-04-07 18:33 I thought I read somewhere that I can enable features like that, though I can't seem to find it again... So, then how come I can compile my code when these options are passed to the compiler, but can't when I leave them out? I've added the project as an attachment. ---------------------------------------------------------------------- Thausand · 2019-04-07 19:06 Quote from: creaothceann on April 07, 2019, 08:33:09 pmI thought I read somewhere that I can enable features like that, though I can't seem to find it again... Sorry, i try and not seem to find. If you see then please write. QuoteSo, then how come I can compile my code when these options are passed to the compiler, but can't when I leave them out? I've added the project as an attachment. Because i wrong and you right  Code: [Select][0.070] Handling option "-MOBJFPC" [0.070] interpreting option "-MOBJFPC" [0.070] Macro defined: FPC_OBJFPC [0.070] Handling option "-MADVANCEDRECORDS" [0.070] interpreting option "-MADVANCEDRECORDS" Note important . other way: Code: [Select][0.055] Handling option "-MADVANCEDRECORDS" [0.055] interpreting option "-MADVANCEDRECORDS" [0.055] Handling option "-MOBJFPC" [0.055] interpreting option "-MOBJFPC" [0.055] Macro defined: FPC_OBJFPC 2.359] Searching file Test_BTB_History.lpr... found [2.359] (TEST_BTB_HISTORY) Load from TEST_BTB_HISTORY (implementation) unit U_TOOLS [2.359] Test_BTB_History.lpr(19,1) (TEST_BTB_HISTORY) Parsing implementation of Test_BTB_History.lpr [2.359] Test_BTB_History.lpr(23,3) Fatal: Syntax error, "identifier" expected but "TYPE" found [2.477] Fatal: Compilation aborted Order important. I not know this possible. Thank you for learn me. ---------------------------------------------------------------------- creaothceann · 2019-04-07 19:20 Quote from: Thausand on April 07, 2019, 09:06:36 pmQuote from: creaothceann on April 07, 2019, 08:33:09 pmI thought I read somewhere that I can enable features like that, though I can't seem to find it again... Sorry, i try and not seem to find. If you see then please write. -Mresult was mentioned on this page: http://wiki.freepascal.org/User_Changes_2.6.0 Quote from: Thausand on April 07, 2019, 09:06:36 pmCode: [Select][0.070] Handling option "-MOBJFPC" [0.070] interpreting option "-MOBJFPC" [0.070] Macro defined: FPC_OBJFPC [0.070] Handling option "-MADVANCEDRECORDS" [0.070] interpreting option "-MADVANCEDRECORDS" Note important . other way: Code: [Select][0.055] Handling option "-MADVANCEDRECORDS" [0.055] interpreting option "-MADVANCEDRECORDS" [0.055] Handling option "-MOBJFPC" [0.055] interpreting option "-MOBJFPC" [0.055] Macro defined: FPC_OBJFPC [2.359] Searching file Test_BTB_History.lpr... found [2.359] (TEST_BTB_HISTORY) Load from TEST_BTB_HISTORY (implementation) unit U_TOOLS [2.359] Test_BTB_History.lpr(19,1) (TEST_BTB_HISTORY) Parsing implementation of Test_BTB_History.lpr [2.359] Test_BTB_History.lpr(23,3) Fatal: Syntax error, "identifier" expected but "TYPE" found [2.477] Fatal: Compilation aborted Order important. I don't really understand these lines... does the compiler automatically define a macro "FPC_OBJFPC" when it encounters these options? I don't have an option "-MOBJFPC" defined, as far as I know the compiler gets "-Mfpc". ---------------------------------------------------------------------- Thausand · 2019-04-07 19:30 Quote from: creaothceann on April 07, 2019, 09:20:18 pm-Mresult was mentioned on this page: http://wiki.freepascal.org/User_Changes_2.6.0 Thank you. I read ... i not seen before. QuoteRemedy: You can reenable the result alias by adding {$modeswitch result} to your program code (after any {$mode macpas} statements), or by using the -Mresult command line option (after any -Mmacpas parameter, and provided there are no {$mode xxx} directives in the source). There also say order important. Quote from: Thausand on April 07, 2019, 09:06:36 pmI don't really understand these lines... does the compiler automatically define a macro "FPC_OBJFPC" when it encounters these options? I don't have an option "-MOBJFPC" defined, as far as I know the compiler gets "-Mfpc". I sorry. It example i use for test  . first: fpc -va -MOBJFPC -MADVANCEDRECORDS Test_BTB_History.lpr last: fpc -va -MADVANCEDRECORDS -MOBJFPC Test_BTB_History.lpr Then see last try then OBJFPC last parameter and overwrite ADVANCEDRECORDS (mode objfpc no have advanced records) If not know: lines are make with -va option ---------------------------------------------------------------------- lucamar · 2019-04-07 19:41 Quote from: creaothceann on April 07, 2019, 09:20:18 pmI don't really understand these lines... does the compiler automatically define a macro "FPC_OBJFPC" when it encounters these options? I don't have an option "-MOBJFPC" defined, as far as I know the compiler gets "-Mfpc". For some (indeed, most) modes and modeswicths the compiler defines some identifiers automatically and undefines some others. As for the ObjFPC, I supposse Thausand just used an example. Quote from: Thausand on April 07, 2019, 09:06:36 pmOrder important. A full mode change implies lots of "small mode" changes; that's why the order is important. In your example, -MOBJFPC automatically deactivates ADVANCEDRECORDS, no matter what you've done before setting the mode. That's why, for example, Lazarus starts programs with:   {$mode objfpc}{$H+} to make sure long-strings are on. ---------------------------------------------------------------------- creaothceann · 2019-04-07 19:48 Quote from: lucamar on April 07, 2019, 09:41:08 pmFor some (indeed, most) modes and modeswicths the compiler defines some identifiers automatically and undefines some others. As for the ObjFPC, I supposse Thausand just used an example.OK... I just never saw log messages like that. Do you know if there is an option to filter/deactivate that specific hint? I don't want to filter all of them. (Besides, now that we know that -M can be used several times, shouldn't the code generating that hint be removed/modified?) EDIT: bug report submitted ---------------------------------------------------------------------- PascalDragon · 2019-04-16 09:20 Quote from: creaothceann on April 07, 2019, 09:48:48 pmQuote from: lucamar on April 07, 2019, 09:41:08 pmFor some (indeed, most) modes and modeswicths the compiler defines some identifiers automatically and undefines some others. As for the ObjFPC, I supposse Thausand just used an example.OK... I just never saw log messages like that. They are disabled by default and only visible when enabled using the -v family of parameters. Quote from: creaothceann link=topic=44963.msg316660#msg316660Do you know if there is an option to filter/deactivate that specific hint? I don't want to filter all of them. (Besides, now that we know that -M can be used several times, shouldn't the code generating that hint be removed/modified?) EDIT: bug report submitted As mentioned in the bug report, this hint is generated by the Lazarus IDE itself, not by FPC. Also please note that passing modeswitches on the command line might not be the best choice as they're reset if a {$mode xxx} is encountered in the code (or if a mode on the command line is passed after a modeswitch). It's safer to simply use an include file with the desired settings.