Comments (4)
Which compiler (and version) are you using? Also on what platform?
from gbdk.
I'm currently running it under Ubuntu 16.04, 64-bit AMD.
Here's my version information for the compilers.
-> % lcc -v
lcc $Id: lcc.c,v 1.6 2001/10/28 18:38:13 michaelh Exp $
-> % sdcc -v
SDCC : gbz80/z80 2.3.1/gbdk-2.96a (Feb 14 2017) (UNIX)
I wrote a test program to showcase what I'm experiencing, maybe I'm just an idiot and I'm missing something huge.
#include <stdio.h> // For debug.
#include <stdlib.h> // Shouldn't malloc be included here?
#include <gb/gb.h>
#include <gb/malloc.h> // Doesn't throw an error finding the header file.
// But nothing gets defined.
// Stupid simple struct.
typedef struct _object {
UBYTE x, y;
BYTE vx, vy;
} object;
void main() {
object *obj = (object *)malloc(sizeof(object)); // Implicit delcaration?
printf("%d", sizeof(obj));
}
If i compile it with lcc -v -c main.c
this is the console output I get:
lcc $Id: lcc.c,v 1.6 2001/10/28 18:38:13 michaelh Exp $
/opt/gbdk/bin/sdcpp -Wall -lang-c++ -DSDCC=1 -DSDCC_PORT=gbz80 -DSDCC_PLAT=gb -DSDCC_MODEL_SMALL -DGB=1 -DGAMEBOY=1 -DINT_16_BITS -D__LCC__ -I/opt/gbdk/include main.c /tmp/lcc45600.i
/opt/gbdk/bin/sdcc -mgbz80 --noinvariant --noinduction --nostdinc --nostdlib --model-small --c1mode /tmp/lcc45600.i /tmp/lcc45601.asm
main.c(15):warning *** function 'malloc' implicit declaration
main.c(15):error *** too many parameters
main.c(15):warning *** function 'malloc' implicit declaration
main.c(16):error *** code not generated for 'main' due to previous errors
lcc: fatal error in /opt/gbdk/bin/sdcc
rm /tmp/lcc45601.asm /tmp/lcc45600.i
Hope that's enough info.
from gbdk.
Thanks for the example. Yes it seems that the malloc.h
does not contain the declaration of malloc()
, you might need to use gbdk-lib/libc/malloc.c
.
I am not really familiar with the code but I could not find usage of malloc()
in any of the example codes. In malloc.h
there is a comment saying "Header for a simple implementation of malloc(). This library may currently be broken.".
There is a newer version of gbdk called gbdk-n but the malloc.h
is the same.
from gbdk.
Yeah, I realized this after a dig through the source code not long after I sent this issue.
Thank you for getting back in touch though!
from gbdk.
Related Issues (20)
- Missing sdcc/bin
- SDCC.lex:45:7: error: redefinition of 'yylineno'
- SDCC.lex:49:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'YY_PROTO' HOT 1
- error: number of arguments doesn't match prototype -- getline() HOT 3
- Build of documentation fails
- Integrate to Travis CI HOT 1
- Binary release
- Debian/Ubuntu .deb packages
- amd64 Linux build HOT 1
- Compilation fails on g++ 4.6.3 (ubuntu, Travis CI) HOT 7
- Build fails on amd64 -- getline() HOT 3
- Windows build
- Shoud BOOLEAN be unsigned?
- Work together with GBDK-N? HOT 3
- Error compiling on cygwin x86-64 (missing typedef?) HOT 1
- Error building on macOS
- Fix INT8 that was unsigned instead of signed HOT 2
- Make error on AWS Cloud9 HOT 1
- MacOS Build HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gbdk.