Azadi
I'm sorry, I should specify. By word I mean the processor word size (32 bits in this example). The sizes of A, B an C are 8, 16 and 32 bits respectively. What I'm wondering is, which of the following will be chosen by the compiler: 1. A, B and C are all 8-bit aligned as long as they fit into a single word boundary (eg. B B _ _, _ B B _ and _ _ B B) are all valid 2. A is 8-bit aligned, B is 16-bit aligned and C is 32-bit aligned (eg. only B B _ _ and _ _ B B) are valid 3. A, B and C are all 32-bit aligned (an entire 32-bit word is reserved for each of the members) I'm specifically curious about which option the compiler will choose on an architecture like x86 where unaligned accesses are allowed, but slower.
I don't have good experience dealt with the way memory manages data in this case but AFAIK each type has its own default alignment on memory and a dependent of the architecture or system. For example, alignof(int) is usually 4, that is, int objects will be stored in addresses divisible by 4. However it's possible to change the alignment of a given standard or user-defined data type using alignas, say: alignas(8) int a{ 22 }; std::cout << &a; 0075FD38 Padding normally happens in classes/structs (easy to be looked up on the Web) and out of them rarely. But nothing is guaranteed I guess. Compilers, through optimizations (allowed when making no change in the observable behavior of the program's output) can do almost anything and likely pack the elements of a container so that they occupy less number of bytes.
Anonymous
Don't you suppose all types char, short and int have their own alignment on memory? std::cout << alignof(char) << ' ' << alignof(short) << ' ' << alignof (int); 1 2 4
Chars by definition are one byte long. So they don't have any alignment requirements. I said ints and shorts have an alignment that is atleast 2. So where exactly did I say that they don't have specific alignment requirements
Azadi
Chars by definition are one byte long. So they don't have any alignment requirements. I said ints and shorts have an alignment that is atleast 2. So where exactly did I say that they don't have specific alignment requirements
I think saying that `char`s also have their own alignment and it's one byte is less ambiguous than saying they don't even have an alignment (both roughly the same thing) short and int types are different, so considering them the same entity and talking about their alignment specs that way is not very correct to me.
Anonymous
I think saying that `char`s also have their own alignment and it's one byte is less ambiguous than saying they don't even have an alignment (both roughly the same thing) short and int types are different, so considering them the same entity and talking about their alignment specs that way is not very correct to me.
When did I talk about chars and ints the same way? Anything that is 1 byte in size by definition does not have an alignment requirement because by definition a byte is the smallest accessible unit of memory. As usual you don't read messages completely and just come in to comment. I already pointed this out in the other C++ community. So please don't do it here as well
Azadi
When did I talk about chars and ints the same way? Anything that is 1 byte in size by definition does not have an alignment requirement because by definition a byte is the smallest accessible unit of memory. As usual you don't read messages completely and just come in to comment. I already pointed this out in the other C++ community. So please don't do it here as well
I read your message there and then replied and said my opinion. (if you're not happy with that, you can take your own). Writing char and int in the message above was a typo, edited to 'short` and 'int' at once. (something you've done above too) Most (if not all) of implementations consider int and short alignments 4 and 2 respectively.
Anonymous
I read your message there and then replied and said my opinion. (if you're not happy with that, you can take your own). Writing char and int in the message above was a typo, edited to 'short` and 'int' at once. (something you've done above too) Most (if not all) of implementations consider int and short alignments 4 and 2 respectively.
No you are wrong. There are so many embedded platforms out there where both shorts and ints are 2 bytes long. And even otherwise the standard for both C and c++ treat both short and int as having the same minimum size requirement which is why I said that their minimum alignment requirement is 2
Chat Boss
CEO_RASTHA is sending messages that looks like a spam.If they sends more spam - like messages, they will be muted. Only admins can unmute them.
Eligible
Pls give me any e books about C++ that completely explain all C++ Roadmaps from beginner till advanced.
XOFF
Wydm all ?
Eligible
Sound's like charity
Could you please gimme
Один
hi!
Один
I'm looking for a C++ developer, I need to change the program interface from GitHuba. I'm crying!!
klimi
Could you please gimme
I am sorry, but no
Eligible
I am sorry, but no
Why u don't want?
Eligible
Sharing is good tho
klimi
Sharing is good tho
cuz it costs me money
Ludovic 'Archivist'
Sharing is good tho
You know that some countries have intellectual property laws right?
Ludovic 'Archivist'
If you subscribe to one of my courses and you use a pdf of a textbook I give you, I have to pay or get sued for pretty threatening amounts of money
Slim
Is there any way to run "pthread.h" files on windows?
Aliyu
Hi guys I'm new here
mito
Hi guys I'm new here
welcome new here.
Aliyu
Slim
Eligible
You know that some countries have intellectual property laws right?
I know you have some free pdf but you are stingy
Slim
Try MinGW
its a compiler right? I'm using this only
Anonymous
its a compiler right? I'm using this only
Hm by this u get access to gcc compiler
Yui
does anyone know how to set intel disassembly flavor on lldb(mac m1), I'm trying to cross compile with m1 mac
Yui
noob on arm mac🥲
Slim
Hm by this u get access to gcc compiler
pthreads lib is not valid for windows, it's more of a platform issue ig rather than compiler
klimi
Stingy
why you don't buy it? hm? why do you keep demanding it from others?
\Device\NUL
whatever, The fact is you are stingy.
B-but have you search across the internet about the book?
Yui
Doesn't AT&T syntax only apply on x86?
I can check At&t syntax after passing -arch = x86 on clang
\Device\NUL
its a compiler right? I'm using this only
Doesn't MinGW have an implementation to pthreads?
\Device\NUL
I can check At&t syntax after passing -arch = x86 on clang
Kinda weird, I though AT&T syntax only apply on x86 instruction
Yui
🫣I don't know, I have not use lldb on m1 chip before : (
Danya🔥
There is only 1 syntax for ARM
Danya🔥
There is only 1 syntax for ARM
At least there are no clear different syntaxes like "Intel" and "at&t"
Yui
thanks, I've already get at&t syntax on it. just wanna change the style
Danya🔥
feel more comfortable with intel-flavor ok?
Dude There are no such thing for ARM assembly
Danya🔥
https://stackoverflow.com/questions/9829136/setting-disassembly-flavour-to-intel-in-lldb
Yui
Are you trying to run x86 binary on ARM Mac ?
cross compile for x86 bin with host m1 mac
Danya🔥
Already tried.... but no use
Try discourse.llvm.org, ask in beginners section or lldb one
Yui
😉ok! thanks
Danya🔥
cross compile for x86 bin with host m1 mac
Does lldb support running x86 binaries on ARM?
Yui
yeah
Yui
support
Yui
gdb doen't
Slim
Doesn't MinGW have an implementation to pthreads?
on Mac OS it's running but not on windows :/
Anonymous
on Mac OS it's running but not on windows :/
I think in mac and Linux already the compiler is installed
Slim
There is no MinGW on Mac
oh my bad, it's GCC
Ludovic 'Archivist'
Ludovic 'Archivist'
I pay around 300€ every year to buy new books partaining to programming, not to mention when I need to buy some egregiously expensive one
Ludovic 'Archivist'
I know you have some free pdf but you are stingy
Just go get the wikibook on what you are trying to learn or pay for your learning material
\Device\NUL
on Mac OS it's running but not on windows :/
Mac OS is also POSIX system that's why its running
\Device\NUL
oh my bad, it's GCC
So it is already solved?
Slim
So it is already solved?
no, Mingw doesn't recognise pthread.h
\Device\NUL
no, Mingw doesn't recognise pthread.h
Hmm, where did you download it?
\Device\NUL
Try to escape the link :D
\Device\NUL
source forge
I mean, where did you download the compiler
\Device\NUL
like path?
the link bruh
\Device\NUL
Or try using MSYS2
Slim
sourceforge . net /projects /mingw /
\Device\NUL
sourceforge . net /projects /mingw /
Did you mind to install MSYS2?
Slim
Or try using MSYS2
will give it a try
Slim
Did you mind to install MSYS2?
heard it for first time :p