xHarbour-org / xharbour

xHarbour is a portable implementation of the Clipper/xBase language (Compiler & complete Run-time libraries). It's practically 100% backward compatible with CA-Clipper 5.2e and 5.3c, and offers many modern language extensions, and extensive Run-time libraries.
http://www.xharbour.org
GNU General Public License v2.0
39 stars 18 forks source link

Argument error on "read" #85

Open rletocart opened 1 month ago

rletocart commented 1 month ago

Hi guys,

I built successfully xHarbour under debian 9,10,11,12 and alpinelinux, both for aarch64 and x86_64, via docker for better automatization. My apps run smoothly under this archs using GT_CRS, GT_TRM and/or GT_CGI.

I lastly got an annoying problem with random errors like "argument error: <>" on a simple read of a string variable... Only some variables, always at same place under any arch.

static datvisu:=""
...

proc majart
...
        if empty(datvisu)
            datvisu := m->dateoftheday-(m->avgsales*30)
            datvisu := beginofthemonth(datvisu)
          endif
          @ row(),col() get datvisu
          read
...          

line read cause argument error: <>

when compiling with xharbour version older than 2023 (I don't have exact date), this is OK... Any idea would help. Thank you guys for this hard work, I'm using xHarbour project since 2000s ;) (Who could at this time say that 20 years later, we can always run our apps, on rpi5 aarch64 inside a docker which did not exist then :))

rletocart commented 1 month ago

My Makefile for any help, I had a long time to write it

CONF_DIR = conf
BUILD_ID_FILE = $(CONF_DIR)/.build_id
ENV_FILE = docker/.env

# Vérifier si le fichier build_id existe, sinon demander à l'utilisateur de saisir IDXLNET
#IDXLNET := $(shell if [ -f $(BUILD_ID_FILE) ]; then cat $(BUILD_ID_FILE); else read -p "Enter IDXLNET: " id; echo $$id > $(BUILD_ID_FILE); cat $(BUILD_ID_FILE); fi)

ifndef IDXLNET
    # Vérifier si le fichier build_id existe
    ifeq ($(shell test -f $(BUILD_ID_FILE) && echo yes),yes)
        IDXLNET := $(shell cat $(BUILD_ID_FILE))
    endif
endif

# Si IDXLNET n'est pas défini à ce stade, demander à l'utilisateur de le saisir
ifndef IDXLNET
    $(error IDXLNET is not defined. Please specify IDXLNET as a parameter or create $(BUILD_ID_FILE))
else
    $(info IDXLNET=$(IDXLNET)) # Afficher la valeur de IDXLNET
    $(shell echo $(IDXLNET) > $(BUILD_ID_FILE))
    $(shell echo "IDXLNET=$(IDXLNET)" > $(ENV_FILE))
endif

#IDXLNET=$(shell cat $(CONF_DIR)/build_id)
VERSION_FILE = version.inc

HB_COMPILER=gcc
HB_GT_LIB=gtcgi
HB_MT=
HB_LEX="SIMPLEX"
HB_MULTI_GT=no

#-lhbcurl -lcurl

# Lire les fichiers PRG et les options depuis les fichiers externes
CONF_DIR = conf
PRGFILES=$(shell cat $(CONF_DIR)/$(IDXLNET).files)
OBJDIR=obj
OBJFILES=$(patsubst %.prg,$(OBJDIR)/%.o,$(PRGFILES))
EXECFILE = bin/linux/stock.linux
OPTIONS_FILE = options.ch
LAST_OPTIONS_FILE = obj/.options.last

options_modified := $(shell diff -q $(OPTIONS_FILE) $(LAST_OPTIONS_FILE) > /dev/null 2>&1 && echo "no" || echo "yes")

ifeq ($(options_modified), yes)
all: rebuild
else
all: $(OPTIONS_FILE) version $(EXECFILE) echo_OK
endif

OS := $(shell uname)

ifeq ($(OS),Darwin)
  HB_LIBS = -lrtl -lgtcgi -lgtcrs -lncurses -lgtstd -llang -lrdd -lvm -lmacro \
  -ldbfcdx -lcommon -lm -lct -ltip -lpp -lcodepage -lgttrm -lhbsix -lpcrepos 

  HB_ARCHITECTURE=darwin
  HB_BIN_INSTALL=/usr/local/bin
  HB_INC_INSTALL=/usr/local/include/xharbour
  HB_LIB_INSTALL=/usr/local/lib/xharbour
  LINK_OPTIONS = $(HB_LIBS)
  CFLAGS = -DHB_FM_STATISTICS_OFF -O3 -fsanitize=address
else
  #HB_LIBS = -lrtl -lgtcgi -lgtcrs -lgtstd -llang -lrdd -lvm -lmacro \
  -ldbfcdx -lcommon -lm -lct -ltip -lpp -lcodepage -lgttrm -lhbsix -lpcrepos 

#  HB_LIBS = -lrtl -lgtcrs -lgtstd -lncurses -ltermcap -llang -lrdd -lvm -lmacro \
#  -ldbfcdx -lcommon -lm -lct -ltip -ltipssl -lssl -lpp -lcodepage -lgttrm -lhbsix -lpcrepos

  HB_LIBS = -lrtl -lgtstd -llang -lrdd -lvm -lmacro \
  -ldbfcdx -lcommon -lm -lct -ltip -ltipssl -lpp -lcodepage -lgttrm -lhbsix -lpcrepos \
  -lgtcrs -lncurses -ltermcap

  HB_ARCHITECTURE=linux
  HB_BIN_INSTALL=/usr/bin
  HB_INC_INSTALL=/usr/include/xharbour
  HB_LIB_INSTALL=/usr/lib/xharbour
  CFLAGS = -DHB_FM_STATISTICS_OFF -O3 -static
  LINK_OPTIONS = -Wl,--start-group $(HB_LIBS) -Wl,--end-group
endif

$(OBJDIR)/%.o: %.prg
    $(HB_BIN_INSTALL)/harbour -kJ -n -go -I$(HB_INC_INSTALL) -a -m -o$@ $<

$(EXECFILE): $(OBJFILES) | $(LAST_OPTIONS_FILE)
    gcc $(CFLAGS) -o $@ $^ -L $(HB_LIB_INSTALL) $(LINK_OPTIONS) 
    @cp $(EXECFILE) bin/linux/$(IDXLNET).linux

clean:
    rm -f $(OBJDIR)/*.o $(OPTIONS_FILE) $(VERSION_FILE) $(EXECFILE) bin/linux/$(IDXLNET).linux $(LAST_OPTIONS) options.ch_Last .options.last

$(LAST_OPTIONS_FILE): $(OPTIONS_FILE)
    cp $< $@

rebuild: clean $(OPTIONS_FILE) version $(EXECFILE) echo_OK

echo_OK:
    @echo "*********************************"
    @echo "COMPILATION OK *** #$(IDXLNET) ***"
    @echo "*********************************"

version:
    ./version.sh

.PHONY: rebuild clean all version

$(OPTIONS_FILE): conf/$(IDXLNET).ch
    cp $< $@
rletocart commented 1 month ago

works even for macosX (darwin), IDXLNET is inside job, can ben ignored