Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Embeddable GCC

Name: Anonymous 2016-09-08 14:56

Is there a small version of GCC for shipping with Windows program? Because Mingw installation takes frigging gigabyte, including a lot of bloat, like C++ and fortran compiler, with useless crap, like directx bindings.

Name: Anonymous 2016-09-16 1:06

The following code prints garbage and segfaults when compiled with TCC on Windows, but works fine with at least one version of MinGW-64 GCC.

#include <stdio.h>

typedef struct meme {
int hax;
char anus;
} meme;

meme mememaker(int n, char c) {
meme ameme;
ameme.hax = n;
ameme.anus = c;
return ameme;
}

int main(void) {
meme kek = mememaker(5,'a');
printf("%d, %c\n", kek.hax, kek.anus);
}


Returning a struct from a function doesn't seem common practice anyhow, more common is to return a pointer to malloc'd storage. And it makes me wonder, a function can't return an array, but if a function can return a struct, can it just return a struct containing nothing but an array? Seems inconsistent to me.

Name: Anonymous 2016-09-16 1:43

>>94
And it makes me wonder, a function can't return an array, but if a function can return a struct, can it just return a struct containing nothing but an array?
I *guess* the issue here is that arrays can have unknown size while structs have fixed size -- which can be a problem when you want to have things returned on stack.

And to clarify, C89 says:
A function declarator shall not specify a return type that is a function type or an array type.
So yes: structs allowed, TCC (seemingly) broken.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List