English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 17 June 2018, 00:44   #1
QBit
Registered User
 
Join Date: Mar 2018
Location: Paderborn/Germany
Posts: 19
Learning how to Code: Question!

Hello I have written a small Addition Program for Amiga Computers.. I managed that it runs with Integer but I don't know how to manage float Operations with vbcc!

This Code works:

Code:
#include <stdio.h>
int main(void) {
  int a; int b; int res;
  printf("\\n\\nWelcome to Amiga Micro Add V.0.0.1\\n\\\n"); 
  printf("\\nPlease enter a Number for Addition : ");
  scanf("%d",&a);
  printf("\\nPlease enter a second Number for Addition: ");
  scanf("%d",&b);
  res = a + b;
  printf("\\nThe result is: %d\\n", res);
  return 0;
}
But this don't:

Code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
  float a; float b; float res;
  printf("\\n\\nWelcome to Amiga Micro Add V.0.0.2\\n\\n");
  printf("\\nPlease enter a Number for Addition : ");
  scanf("%f",&a); printf("\\nPlease enter a second Number for Addition: ");
  scanf("%f",&b);
  res = a + b;
  printf("\\nThe result is: %f\\n", res);
  return 0;
}
The VBCC Compiler complains: Error 21 Reference to undefined symbol __ieees2d. vlink error

I did it with WinUAE configured with a 68040 CPU!
QBit is offline  
Old 17 June 2018, 01:04   #2
QBit
Registered User
 
Join Date: Mar 2018
Location: Paderborn/Germany
Posts: 19
Solved!

Both Codes are correct!

I found the Error you have to compile with the -lmieee Option

Compile Command:
vc -o microadd.exe microadd.c -lmieee

then it works!
QBit is offline  
Old 18 June 2018, 12:22   #3
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,502
Quote:
Originally Posted by QBit View Post
I found the Error you have to compile with the -lmieee Option
Explanation: The standard clib (vc.lib) does not include floating point support to keep programs small. When linking with the mlib (mieee.lib for soft-float) several functions (like printf, scanf, etc.) are replaced by extended versions with floating point included.
phx is offline  
Old 18 June 2018, 13:07   #4
Hewitson
Registered User
 
Hewitson's Avatar
 
Join Date: Feb 2007
Location: Melbourne, Australia
Age: 41
Posts: 3,773
QBit: Can you please post the file sizes of both executables? I'm interested to see how much -lmieee increases the file size.
Hewitson is offline  
Old 18 June 2018, 21:18   #5
QBit
Registered User
 
Join Date: Mar 2018
Location: Paderborn/Germany
Posts: 19
Hewitson, the Integer version without -lmieee has 12.876 bytes as exe,, and the float with -lmieee Option has 18.780 bytes! Quite big Monsters of Programms! *lol*
QBit 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
Epic: Is the sound code broken after a while? + question about the music + HOL cheat lilalurl support.Games 6 26 May 2019 21:32
Learning C nobody Coders. C/C++ 28 15 June 2016 08:07
Wanting to start learning to code amiga in asm fishyfish Coders. Asm / Hardware 5 03 March 2012 06:11
Suggestions for learning pmc Coders. Tutorials 248 20 October 2010 21:42
A question for those of you who can look into a games code. Ironclaw Retrogaming General Discussion 22 28 January 2005 22:00

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 09:37.

Top

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