English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 31 May 2021, 15:00   #1
alancfrancis
Registered User
 
alancfrancis's Avatar
 
Join Date: Jun 2020
Location: Scotland
Posts: 146
non-constant TagList values and SASC6.58

As usual asking the question here in the hope that 2 minutes later I'll figure it out myself....

I've been trying to remember everything I forgot about intuition and gadtools so have been working on a super simple little thing to create screens and windows and requesters and an Arexx port. SO far, so good, all built with bebbo's GCC.

Since receiving AmigaOS3.2 I've been trying to set up an on-amiga environment with SAS6.58.

I assumed it would be pretty easy to recompile my super-simple code but alas no.

I'm getting an error on both OpenScreenTagList and OpenWindowTagList complaining about "invalid constant expressions" where I am passing, for example, a STRPTR into the SA/WA_Title tags and where I pass a Screen* into the WA_PubScreen tag.

I can't see how I can make these work (especially the screen) with constants and I'm a bit out of my depth already with the brainbending world of SAS :-)

Why does SAS think they have to be constants? How can I convince SAS it's just fine to pass these pointers as ULONGs :-)

Any suggestions welcome.

Last edited by alancfrancis; 31 May 2021 at 15:23.
alancfrancis is offline  
Old 31 May 2021, 16:54   #2
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
You should post the code which causes the error. The message alone says nothing about what you did wrong.

Normally one would use the varargs functions OpenWindowTags and OpenScreenTags and pass the tag list on the stack.

If you use ...TagList, then you have to declare the tag list as array of struct TagItem and cast every pointer to ULONG when you assign it to ti_Data.
thomas is offline  
Old 31 May 2021, 17:09   #3
alancfrancis
Registered User
 
alancfrancis's Avatar
 
Join Date: Jun 2020
Location: Scotland
Posts: 146
Quote:
Originally Posted by thomas View Post
You should post the code which causes the error. The message alone says nothing about what you did wrong.

Normally one would use the varargs functions OpenWindowTags and OpenScreenTags and pass the tag list on the stack.

If you use ...TagList, then you have to declare the tag list as array of struct TagItem and cast every pointer to ULONG when you assign it to ti_Data.
Sure, the code is not very interesting and works fine on GCC and VBCC which is why I didn't post it. :-)

SCREENPTR and WNDPTR are my own typedefs for struct Screen* and struct Window*

SAS gives me errors on the SA_Title, WA_Title and WA_PubScreen lines complaining that they are non-constant expressions (and SAS is correct, they aren't, but why care... VBCC and GCC don't ?)

Code:
SCREENPTR CreateWorkbenchLikeScreen(STRPTR name) {
   struct TagItem screenTags[] = {
      SA_Title, (ULONG)name,
      SA_LikeWorkbench, 1,
      TAG_DONE,
   };

   SCREENPTR result = OpenScreenTagList(NULL, &screenTags[0]);
   if( result ) {
      SCREENDATAPTR data = (SCREENDATAPTR)AllocVec(sizeof(struct MyScreenData), MEMF_CLEAR);
      data->visualInfo = GetVisualInfo(result, TAG_END);
      result->UserData = (APTR)data;
   }
   return result;
}
and

Code:
WNDPTR CreateWindow(STRPTR name, SCREENPTR screen) {
   struct TagItem winTags[] = {
      WA_Title, (ULONG)name,
      WA_Left, 0, 
      WA_Top, 11,
      WA_Width, 640, 
      WA_Height, 245,
      WA_MinHeight, 100,
      WA_MinWidth, 320,
      WA_IDCMP, IDCMP_CLOSEWINDOW|IDCMP_MENUPICK,
      WA_Flags, WFLG_SIZEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET | WFLG_ACTIVATE | WFLG_NEWLOOKMENUS,
      WA_PubScreen, (ULONG)screen,
      TAG_DONE
   };

   WNDPTR result = OpenWindowTagList(NULL, &winTags[0]);
   return result;
}
alancfrancis is offline  
Old 31 May 2021, 17:48   #4
vbc
Registered User
 
Join Date: Jan 2021
Location: Germany
Posts: 18
Quote:
Originally Posted by alancfrancis View Post
SAS gives me errors on the SA_Title, WA_Title and WA_PubScreen lines complaining that they are non-constant expressions (and SAS is correct, they aren't, but why care... VBCC and GCC don't ?)
C90 requires compound initializers to be constant. C99 removed this restriction, but SAS/C development stopped before the arrival of C99.
vbc is offline  
Old 31 May 2021, 17:50   #5
alancfrancis
Registered User
 
alancfrancis's Avatar
 
Join Date: Jun 2020
Location: Scotland
Posts: 146
Quote:
Originally Posted by vbc View Post
C90 requires compound initializers to be constant. C99 removed this restriction, but SAS/C development stopped before the arrival of C99.
Thanks!

I've been coding in ObjectiveC so long I've forgotten how bad C used to be :-)
alancfrancis is offline  
Old 31 May 2021, 17:59   #6
alancfrancis
Registered User
 
alancfrancis's Avatar
 
Join Date: Jun 2020
Location: Scotland
Posts: 146
Quote:
Originally Posted by vbc View Post
C90 requires compound initializers to be constant. C99 removed this restriction, but SAS/C development stopped before the arrival of C99.
Switched to OpenWindowTags and OpenScreenTags and all well. Thanks!
alancfrancis is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Do you need to have a constant Internet Connection? mightydimo support.FS-UAE 2 27 January 2021 00:49
A1200 HD LED constant flashing WildW support.Other 4 05 January 2019 15:04
A1200 constant reset kipper2k support.Hardware 0 06 January 2015 18:34
A4000 constant reboot desantii support.Hardware 2 07 August 2011 01:13

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:17.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07148 seconds with 13 queries