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: 9191
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
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: 9191
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
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
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: 31
jack2
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: 3170
Location: Denmark
f0dder
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
Location: Michigan, USA
windwakr
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: 9191
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
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
Location: Michigan, USA
windwakr
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: 9191
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
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
Location: Michigan, USA
windwakr
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: 213
Location: Budapest, Hungary
Endre
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.