Giter Site home page Giter Site logo

Memory functions not working. about gbdk HOT 4 CLOSED

SeedyROM avatar SeedyROM commented on August 16, 2024
Memory functions not working.

from gbdk.

Comments (4)

gheja avatar gheja commented on August 16, 2024

Which compiler (and version) are you using? Also on what platform?

from gbdk.

SeedyROM avatar SeedyROM commented on August 16, 2024

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.

gheja avatar gheja commented on August 16, 2024

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.

SeedyROM avatar SeedyROM commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.