Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
passing strings byval into a subroutine - avr-gcc erroir

 
Post new topic   Reply to topic    Forum Index -> ZBasic Native Mode
Author Message
ndudman



Joined: 25 Dec 2008
Posts: 79

Posted: 09 January 2009, 21:50 PM    Post subject: passing strings byval into a subroutine - avr-gcc erroir Reply with quote

Hi

I don't get a avr-gcc compiler error if the sub takesastring is defined as byref, if its defined as below, i.e byval then i get the below errors... full at end of message.
    undefined reference to `FIX_PARM_STR'


With the following code

Code:
sub takesastring(byval str as string)

end sub

Sub Main()
   Dim str as string = "a string"
   call takesastring(str)
End Sub


I get the following error
    >"C:\PROGRAM FILES\ZBASIC\zbasic.exe" --target-device=ZX24n --directory="C:/" --project="test7.pjt"
    make: Entering directory `C:/zxTempDir/test7'
    avr-gcc -c -Dzx24n -mmcu=atmega644p -std=gnu99 -fgnu89-inline -gdwarf-2 -Os -I"C:/PROGRAM FILES/ZBASIC/zxlib" -I. -Wall -Wstrict-prototypes -funsigned-char -fpack-struct test7.c -o test7.o
    test7.c: In function 'zf_takesastring':
    test7.c:53: warning: implicit declaration of function 'FIX_PARM_STR'
    test7.c:55: warning: implicit declaration of function 'FREE_PARM_STR'
    test7.c:53: warning: 'strTypeSave1' is used uninitialized in this function
    avr-gcc -o test7.i1 -mmcu=atmega644p -L"C:/PROGRAM FILES/ZBASIC/zxlib" -Wl,-T,"C:/PROGRAM FILES/ZBASIC/zxlib/zx_avr5.lds" -u rtc_ISR -u default_ISR test7.o -lzx24n -lm
    test7.o: In function `zf_takesastring':
    C:\zxTempDir\test7/test7.c:53: undefined reference to `FIX_PARM_STR'
    C:\zxTempDir\test7/test7.c:55: undefined reference to `FREE_PARM_STR'
    make: *** [test7.i1] Error 1
    make: Leaving directory `C:/zxTempDir/test7'
    Error: one or more errors occurred in the back-end build process for "test7.zxb"
    >Exit code: 1


Thanks
Neil
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2493
Location: Portland, OR

Posted: 09 January 2009, 22:36 PM    Post subject: Re: passing strings byval into a subroutine - avr-gcc erroir Reply with quote

ndudman wrote:
Code:

C:\zxTempDir\test7/test7.c:53: undefined reference to `FIX_PARM_STR'
C:\zxTempDir\test7/test7.c:55: undefined reference to `FREE_PARM_STR'
Both of those identifiers are defined in zxlib.h and I've confirmed that the v2.6.9 installer contains a version of that file that has the definitions. If you originally used an earlier installer (perhaps as late as v2.6.6) and you're now using the v2.6.10 compiler, that would explain the problem.

Perhaps the simplest way to correct this issue is to download the v2.6.4 ZX Library .zip file and extract the files in it to the zxlib directory of the ZBasic installation directory. You can find a link to that .zip file on the downloads page or using the link below.

http://www.zbasic.net/downloads.php#zxlib
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2493
Location: Portland, OR

Posted: 09 January 2009, 22:37 PM    Post subject: Reply with quote

I just realized that the output in your original post indicates that a makefile is being used for the back end build. Which version of the compiler did you use to produce that result?
Back to top
ndudman



Joined: 25 Dec 2008
Posts: 79

Posted: 09 January 2009, 22:46 PM    Post subject: Reply with quote

It was the latest NON experimental from download page of website 2.6.9... i installed only the compiler download

However I just got the same error when I compiled (passing strings as byval) using the experimental 2.6.9.10.

If it helps any when I use byref the FREE_PARM_STR etc arnt inserted into the c functions (end and begining) but when byval they are and hence the error. I confirm this with the latest 2.6.9.10

Neil
Back to top
ndudman



Joined: 25 Dec 2008
Posts: 79

Posted: 09 January 2009, 22:57 PM    Post subject: Reply with quote

Sorry I forgot to add that I also have in project file
--optimize=no-unreferenced-code
If I remove this then I dont get the problem, I was worried that the problematic function/subs that caused it were perhaps being optimized out (perhaps not) so I called one directly from Main() and did not get an error when the --optimize=no-unreferenced-code option was NOT used, but do get problem when it is used.

Neil
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2493
Location: Portland, OR

Posted: 09 January 2009, 23:05 PM    Post subject: Reply with quote

ndudman wrote:
It was the latest NON experimental from download page of website 2.6.9... i installed only the compiler download
I believe, then, that that means that you did the original ZBasic installation by using the v2.6.6 or earlier installer. I'm fairly certain that the zxlib.h file included with the older installers does not have the FREE_PARM_STR macro defined. You can confirm this by loading zxlib.h into any editor and searching for that string.

If it is missing, you can correct the problem by extracting the files from the v2.6.4 ZX Library to the zxlib subdirectory of the ZBasic installation directory.
Back to top
ndudman



Joined: 25 Dec 2008
Posts: 79

Posted: 10 January 2009, 8:40 AM    Post subject: Reply with quote

As I remember correctly I installed zbasic a few weeks ago from the version of the zbasic installer just prior to the latest on the website which was 2.6.5

Just done what you suggested in last post... and it did the trick.

Thanks
Neil
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Native Mode Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group