flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > typedef struct using tcc (tiny c compiler)

Author
Thread Post new topic Reply to topic
sleepsleep



Joined: 05 Oct 2006
Posts: 13075
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 06 Aug 2009, 21:35
i am pondering regarding its results.

Code:
#include <stdio.h>
#include <stdlib.h>

struct account {
 int no;
     char name[20];
};

typedef struct _car {
 int no;
     char name[20];
} car;

typedef struct _lorry {
   int no;
     char name[20];
} lorry, *lorry;

int main(void) {

    struct account s;
   s.no = 405;
 printf("%lu \n", s.no);
  printf("sizeof s = %lu \n", sizeof(s));

      car m;
      m.no = 321;
 printf("%lu \n", m.no);
  printf("sizeof m = %lu \n", sizeof(m));

      lorry *l;
   printf("sizeof *l = %lu \n", sizeof(*l));
        printf("sizeof l = %lu \n", sizeof(l));

      lorry c;
    printf("sizeof c = %lu \n", sizeof(c));

      return(0);
}
    


the result is
Code:
405
sizeof s = 24
321
sizeof m = 24
sizeof *l = 4
sizeof l = 4
sizeof c = 4
    


i am quite certain that the sizeof c should be 24. (same as sizeof m).
is this compiler error somehow?
Post 06 Aug 2009, 21:35
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 13075
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 06 Aug 2009, 21:40
i think somehow i found the reason.
tcc doesn't throw warning or error on conflicting types.

Code:
typedef struct _lorry {
        int no;
        char name[20];
} lorry, *plorry; 
    

would make c = 24;
Post 06 Aug 2009, 21:40
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 07 Aug 2009, 07:53
That typedef immediately struck me. Got to try it with some normal C compiler.
Post 07 Aug 2009, 07:53
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
jack2



Joined: 06 Jul 2008
Posts: 33
jack2 07 Aug 2009, 13:17
in visual studio 2005 I get
Quote:

405
sizeof s = 24
321
sizeof m = 24
sizeof *l = 24
sizeof l = 4
sizeof c = 24

btw, had to remove *lorry from
Code:
typedef struct _lorry { 
        int no; 
        char name[20]; 
} lorry, *lorry;
    

because i get
Quote:

error C2040: 'lorry' : '_lorry *' differs in levels of indirection from '_lorry'
Post 07 Aug 2009, 13:17
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 07 Aug 2009, 14:00
Why keep on using TCC instead of a decent compiler?
Post 07 Aug 2009, 14:00
View user's profile Send private message Visit poster's website Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 07 Aug 2009, 14:18
What other compiler takes under a megabyte of space unpacked and doesn't have to install itself?


BTW:
It's called a Truck. Seriously, "Jolly good day, did you see that lorry go by?". Those englanders have the weirdest words and phrases.

_________________
----> * <---- My star, won HERE
Post 07 Aug 2009, 14:18
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 13075
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 07 Aug 2009, 16:54
Quote:

Why keep on using TCC instead of a decent compiler?

i actually thought of using PCC too, since openbsd dev wanna uses them, it won't be wrong, but couldn't find the win32 version.
http://en.wikipedia.org/wiki/Portable_C_Compiler

windwakr wrote:

those tiny small words

yeah, those englanders.
lorry. even the national language here in my country, borrow this word directly.

lorry = lori
Post 07 Aug 2009, 16:54
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 07 Aug 2009, 17:33
this?
http://pcc.ludd.ltu.se/supported-platforms/
http://pcc.ludd.ltu.se/ftp/pub/win32/
Google is your friend.

EDIT2: Ok, forget my last edit(that is, if you read it). Download this file. http://pcc.ludd.ltu.se/ftp/pub/win32/pcc-20090408-win32.exe


Ok, lorry to us is strange. But I bet some of our words are probably strange to you.

_________________
----> * <---- My star, won HERE


Last edited by windwakr on 07 Aug 2009, 17:43; edited 1 time in total
Post 07 Aug 2009, 17:33
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 13075
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 07 Aug 2009, 17:41
weird, why they hide this information in their download page.
http://pcc.ludd.ltu.se/downloads/

yeah, strange, btw, i think you just introduce fasm board with new message encryption utility, size=1 Laughing
Post 07 Aug 2009, 17:41
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 07 Aug 2009, 17:55
It IS a wiki, you could sign up and add the links yourself.

I haven't introduced anything, me and many others have been using size=1 for years.

_________________
----> * <---- My star, won HERE
Post 07 Aug 2009, 17:55
View user's profile Send private message Reply with quote
Endre



Joined: 29 Dec 2003
Posts: 215
Location: Budapest, Hungary
Endre 23 Aug 2009, 11:35
I think that pcc is not a serious alternative for replacing gcc, but there are huge expectations in clang. You might want to take a look also at the llvm compiler infrastructure that's the engine under the cover. As I know C, and Objective-C are quite matured (Apple pushes the development hard) but there may still be problems with C++ (I simply don't know why this language is not forbidden yet Sad). The source can of course be downloaded and compiled. I had absolutely no problem with the compilation. On the other hand I doubt that it is less than 1MiB.
Post 23 Aug 2009, 11:35
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.