English Amiga Board


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

 
 
Thread Tools
Old 08 June 2023, 06:24   #1
Inner200k
Registered User
 
Join Date: May 2023
Location: Christchurch, New Zealand
Posts: 33
SAS/C 6/58 printf() no prototype

I do not understand;

Code:
#include <stdio.h>

int main() {
printf("Hello World\n");
return 0;
}
Results in

Code:
SAS/C Amiga Compiler 6.58
Copyright (c) 1988-1995 SAS Institute Inc.

====================
   printf[(]"Hello World\n"); print.c 4 Warning 100: no prototype declared for function "printf"

Slink - Version 6.58
Copyright (c) 1988-1995 SAS Institute, Inc.  All Rights Reserved.
SLINK Complete - Maximum code size = 7560 ($00001d88) bytes
Final output file size = 7568 ($00001d90) bytes
I've used [ & ] to illustrate where the highlighted cursor is pointing to in the error log.

Code this simplistic shouldn't produce this error and I'm trying to fix it before I do anything more meaningful, it should be said that the code at least on my system runs and works as expected regardless of the prototype error, however warnings can often be an indication that something is wrong and can lead to problems in time.

Inner200k is offline  
Old 08 June 2023, 08:53   #2
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
It's just a warning that you aren't checking the return code of printf().
Samurai_Crow is offline  
Old 08 June 2023, 17:54   #3
Docent
Registered User
 
Join Date: Mar 2019
Location: Poland
Posts: 59
Quote:
Originally Posted by Samurai_Crow View Post
It's just a warning that you aren't checking the return code of printf().
This is incorrect - checking for types of return values on prototypes is performed when there is an explicit assignment of a return value to a variable, otherwise the check is ignored and no warning is generated.

Such warning appears when compiler cannot find the correct prototype for a function - perhaps the included stdio.h file is incorrect or damaged.
I compiled this code on my amiga and i did not get any warning.
Docent is offline  
Old 09 June 2023, 00:47   #4
freakofnature
Registered User
 
Join Date: Jan 2021
Location: Darksideofthemoon
Posts: 69
deleted!
i checked if a wrong assignment could cause that, but then no executable will be build.
i'm sure, i encountered this in the past as well.

Last edited by freakofnature; 09 June 2023 at 01:03.
freakofnature is offline  
Old 09 June 2023, 14:27   #5
rkidd7952
Registered User
 
Join Date: Aug 2012
Location: Champaign IL USA
Posts: 22
The compiler might be finding an unexpected file named stdio.h in its header search path. Try running only the preprocessor (sc pponly print.c), then check the output.

Robert
rkidd7952 is offline  
Old 19 June 2023, 08:53   #6
Inner200k
Registered User
 
Join Date: May 2023
Location: Christchurch, New Zealand
Posts: 33
Quote:
Originally Posted by Docent View Post
This is incorrect - checking for types of return values on prototypes is performed when there is an explicit assignment of a return value to a variable, otherwise the check is ignored and no warning is generated.

Such warning appears when compiler cannot find the correct prototype for a function - perhaps the included stdio.h file is incorrect or damaged.
I compiled this code on my amiga and i did not get any warning.
kind of what I thought too when reading your comments that it was incorrect, although when I first saw the error I simply thought this is by no means normal behaviour for a freshly installed AmigaOS 3.1.4 & SASC 6.58 to behave at all, it's still spewing out those errors it's now at a stage where it's inhibiting me from being able to see actual errors in my code.

I checked my stdio.h to see if was corrupted, hoping it wasn't there and ... it is just as it has always been for decades lol.

stdio.h
extern int printf(const char *, ...);

Just spitballin here, couldn't be because of an updated os?
Am I missing a required .lib? -- according to snoopdos maybe an issue with sc.lib ?
maybe a compiler option? I'm using "sc <sourcefile> link <outputfile>" ?

Last edited by Inner200k; 19 June 2023 at 09:13.
Inner200k is offline  
Old 19 June 2023, 10:14   #7
modrobert
old bearded fool
 
modrobert's Avatar
 
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 775
I get no warning when compiling your source code using 'sc hello_world.c'.

How does your SAS/C assigns look (check with 'assign' in shell)?

In my s:Startup-Sequence (actually User-Startup in my case) the following lines were added:

Code:
;BEGIN SAS/C
assign sc: sys:programs/sasc
assign lib: sc:lib
assign include: sc:include
assign cxxinclude: sc:cxxinclude
path sc:c add
;END SAS/C
modrobert is offline  
Old 19 June 2023, 10:24   #8
Inner200k
Registered User
 
Join Date: May 2023
Location: Christchurch, New Zealand
Posts: 33
Quote:
Originally Posted by modrobert View Post
I get no warning when compiling your source code using 'sc hello_world.c'.

How does your SAS/C assigns look (check with 'assign' in shell)?

In my s:Startup-Sequence (actually User-Startup in my case) the following lines were added:

Code:
;BEGIN SAS/C
assign sc: sys:programs/sasc
assign lib: sc:lib
assign include: sc:include
assign cxxinclude: sc:cxxinclude
path sc:c add
;END SAS/C
Mine looks simular

Quote:
Assign >NIL: SC: Sys:Tools/sasc658/sc
Assign >NIL: LIB: SC:lib

Assign >NIL: INCLUDE: SC:netinclude <--- maybe swap these around
Assign >NIL: INCLUDE: SC:include ADD <--- maybe swap these around.

Assign >NIL: NETINCLUDE: SC:netinclude
Assign >NIL: CXXINCLUDE: sc:cxxinclude
Inner200k is offline  
Old 19 June 2023, 10:29   #9
Inner200k
Registered User
 
Join Date: May 2023
Location: Christchurch, New Zealand
Posts: 33
Thumbs up

I fixed up my assigns ... that was the issue! goodness.
Inner200k 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
SAS/C 6.58 on 1.3 marduk_kurios Coders. C/C++ 25 29 July 2018 18:17
SAS C 6.58 (again) nyteshade request.Other 2 15 December 2016 17:18
Using AHI dev with SAS/C 6.58 8bitbubsy Coders. General 5 09 August 2011 02:50
Sas C 6.58 AmiCoder request.Apps 3 06 February 2010 01:19
SAS C/C++ 6.58 manual? ableeker Coders. General 15 23 October 2008 22:05

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 06:31.

Top

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