Menu

#1000 '__FB_ARGC__' and '__FB_ARGV__' don't work with '-r' switch

closed
nobody
None
compiler
2024-03-30
2024-01-16
Erik Siers
No

When compiling with the '-r' switch under DOS, Win32, or Win64 (and presumably other systems), FB_ARGC and FB_ARGV are not defined, but when omitting '-r' they are:

D:\Win64tools\Programming\FreeBASIC>type tst.bas
print __FB_ARGC__
print *__FB_ARGV__[0]

D:\Win64tools\Programming\FreeBASIC>fbc64 -version
FreeBASIC Compiler - Version 1.10.1 (2023-12-24), built for win64 (64bit)
Copyright (C) 2004-2023 The FreeBASIC development team.
standalone

D:\Win64tools\Programming\FreeBASIC>fbc64 tst.bas

D:\Win64tools\Programming\FreeBASIC>tst.exe
 1
tst.exe

D:\Win64tools\Programming\FreeBASIC>fbc64 -r tst.bas
tst.bas(1) error 42: Variable not declared, __FB_ARGC__ in 'print __FB_ARGC__'
tst.bas(2) error 42: Variable not declared, __FB_ARGV__ in 'print *__FB_ARGV__[0]'

Discussion

  • Jeff Marshall

    Jeff Marshall - 2024-01-21

    Try:
    fbc64 -r tst.bas -m tst

    See:
    -r option

    When using the -r option, -m must be specified when compiling the main module

    And see also: -m option, __FB_ARGC__

    __FB_ARGC__ and __FB_ARGV__ are defined for the implicit main function in the main module only.

    -r option overrides fbc's normal decision making about what to build and therefore fbc will not automatically infer that the module to translate is a main module.

     
  • Erik Siers

    Erik Siers - 2024-01-21

    Ah, I apologize. I never noticed that bit about '-m' before. Sorry for the inaccurate report.

     
  • Jeff Marshall

    Jeff Marshall - 2024-03-30

    Thank-you for the report!

     
  • Jeff Marshall

    Jeff Marshall - 2024-03-30
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB