LONGINT causing problems
LONGINT causing problems
Switched some variables in a program from INTEGER to __LONGINT (I am using -lang qb), now FBC compiler throws this error:
PROGRAM.o: In function 'main':
PROGRAM.c:(.text+0x2bdf3): undefined reference to '__moddi3'
PROGRAM.c:(.text+0x2be9e): undefined reference to '__moddi3'
Help?
PROGRAM.o: In function 'main':
PROGRAM.c:(.text+0x2bdf3): undefined reference to '__moddi3'
PROGRAM.c:(.text+0x2be9e): undefined reference to '__moddi3'
Help?
Re: LONGINT causing problems
Well, AFAIR, in: lang "QB" a Integer = Short (in lang "FB", aka: 16bit 'integer-type').
A LongInt (64bit) is therefore, 4 x SizeOf(Short), I'd try to use __Long instead (32bit).
I've never used -lang "QB", and never will (for obvious reasons).
The best bet, IMHO is, to switch to: -lang "FB" ...
Questions: which OS (32/64) ? which FBC (32/64bit) ?
A LongInt (64bit) is therefore, 4 x SizeOf(Short), I'd try to use __Long instead (32bit).
I've never used -lang "QB", and never will (for obvious reasons).
The best bet, IMHO is, to switch to: -lang "FB" ...
Questions: which OS (32/64) ? which FBC (32/64bit) ?
Last edited by MrSwiss on Oct 17, 2017 18:02, edited 1 time in total.
Re: LONGINT causing problems
Hi, it looks like a bug with the -lang qb code generation on 64bit. I'm going to make a bug report.
Re: LONGINT causing problems
Skystrick: I'm not being able to reproduce your error. I create a simple program using -lang qb and one Integer variable and it compiles and runs fine. I change the variable to __LongInt and it still runs perfectly. Can you post the code?
Also, MrSwiss is right. The QB dialect is there so that you can compile old QB programs with FB with little to no changes. If you're actually making changes to it, then you should seriously consider porting it to FB's native dialect unless it's just a minor touch you want to make. If you're building a new program, then you definitely should not use QB dialect. Of course, this does not respond to your initial question, so if you post your code, we can hopefully help more.
EDIT: Maybe it has to do with the platform? I'm compiling under GNU/Linux 32bit.
Also, MrSwiss is right. The QB dialect is there so that you can compile old QB programs with FB with little to no changes. If you're actually making changes to it, then you should seriously consider porting it to FB's native dialect unless it's just a minor touch you want to make. If you're building a new program, then you definitely should not use QB dialect. Of course, this does not respond to your initial question, so if you post your code, we can hopefully help more.
EDIT: Maybe it has to do with the platform? I'm compiling under GNU/Linux 32bit.
Re: LONGINT causing problems
Thanks! Any suggestions for a workaround? Or just wait for a patch?dkl wrote:Hi, it looks like a bug with the -lang qb code generation on 64bit. I'm going to make a bug report.
I'm compiling under Ubuntu Linux 64-bit using FBC 1.05.0 (linux-x86_64)xlucas wrote:EDIT: Maybe it has to do with the platform? I'm compiling under GNU/Linux 32bit.
This is a 64-bit bug so you were unable to reproduce it under 32-bit linux.
My programs require QB syntax, not looking to debate that point in this or any of my other threads. Thank you.MrSwiss wrote:I've never used -lang "QB", and never will (for obvious reasons).
The best bet, IMHO is, to switch to: -lang "FB" ...
Re: LONGINT causing problems
hello skystrick
this code compiles and runs ok using FreeBASIC Compiler - Version 1.06.0 (02-04-2017), built for linux-x86_64 (64bit)
my suggestion, try the latest fb build from http://users.freebasic-portal.de/stw/builds/ or get the git repo from https://github.com/freebasic/fbc and make and install.
if my example above does not throw the expected error then please post code that does not compile.
this code compiles and runs ok using FreeBASIC Compiler - Version 1.06.0 (02-04-2017), built for linux-x86_64 (64bit)
Code: Select all
#lang "qb"
dim as __LONGINT x
input "enter x ";x
print sqr(x)
print "enter return to exit "
sleep
if my example above does not throw the expected error then please post code that does not compile.
Re: LONGINT causing problems
Seldom, on this forum, I've had to read such NONSENSE (you, might require), but not the compiler/program e.t.c.!skystrick wrote:My programs require QB syntax
As you wish, you'll be IGNORED in future (rather, your posts here), just made it to the 'list', congratulations!
Re: LONGINT causing problems
Please read the dkl's bug report:
#868 Odd code generation for longint div/mod in -lang qb
#868 Odd code generation for longint div/mod in -lang qb
Re: LONGINT causing problems
Your code does compile and run without error on my system.srvaldez wrote:hello skystrick
this code compiles and runs ok using FreeBASIC Compiler - Version 1.06.0 (02-04-2017), built for linux-x86_64 (64bit)Code: Select all
#lang "qb" dim as __LONGINT x input "enter x ";x print sqr(x) print "enter return to exit " sleep
Something's going wrong with my code, but only when I use __LONGINT instead of INTEGER.
How can I decode the error locations (".text+0x2bdf3" and ".text+0x2be9e") to find what's going wrong in the .c file created by the compiler?
My code's over 20,000 lines long or I'd post it.
Re: LONGINT causing problems
thanks fxm, yes indeed there's a problem.
Re: LONGINT causing problems
if your code uses mod or division (have not tried the other operators) then there'a problem.
Re: LONGINT causing problems
srvaldez wrote:if your code uses mod or division (have not tried the other operators) then there'a problem.
Nailed it!
I used MOD twice :)
Wait for a bugfix or is there a workaround for MOD in 64-bit lang QB?
Re: LONGINT causing problems
may I suggest that you use QB64 instead of FB http://www.qb64.net or https://www.qb64.org forum http://www.qb64.net/forum/index.php
Re: LONGINT causing problems
I depend on several commands/features supported only by FreeBASIC (even in -lang qb). 20,000+ lines of code in my program would be a lot to rewrite.srvaldez wrote:may I suggest that you use QB64 instead of FB http://www.qb64.net or https://www.qb64.org forum http://www.qb64.net/forum/index.php
Without MOD, I need another way to determine whether Number X is evenly divisible by Number Y.
Currently I test whether X MOD Y = 0 is true (if it is, there is no remainder for X DIV Y, thus it is evenly divisible).
What is another way to do this without using MOD or DIV?
Re: LONGINT causing problems
I think I solved my own problem:skystrick wrote:Without MOD, I need another way to determine whether Number X is evenly divisible by Number Y.
Currently I test whether X MOD Y = 0 is true (if it is, there is no remainder for X DIV Y, thus it is evenly divisible).
What is another way to do this without using MOD or DIV?
Code: Select all
A = 1
DO
IF Y * A = X THEN REMAINDER = "NO": EXIT DO
IF Y * A > X THEN REMAINDER = "YES": EXIT DO
A = A + 1
LOOP
It starts at the lowest multiple of Y (1*Y) and increments up the multiples of Y (2*Y, 3*Y, 4*Y, etc.) until ether it hits a multiple which is equal to X (exits with remainder variable set to "NO"), or until it reaches a multiple which exceeds the value of X (exits with remainder variable set to "YES", because no multiple of Y will equal X).
Anyone spot a problem?