kbhearn wrote:the point is that uint64_t from <stdint.h> is a standard-defined way to request an exactly 64 bit unsigned int while __int64 is an implementation-defined token. It's not a huge difference though.
So I should be able to use uint64_t and still typedef to u64. I'll give it a try.
EDIT: No such file as stdint.h or inttypes.h
Last edited by Michael Sherwin on Tue Jan 19, 2016 2:13 pm, edited 1 time in total.
If you are on a sidewalk and the covid goes beep beep
Just step aside or you might have a bit of heat
Covid covid runs through the town all day
Can the people ever change their ways
Sherwin the covid's after you
Sherwin if it catches you you're through
kbhearn wrote:the point is that uint64_t from <stdint.h> is a standard-defined way to request an exactly 64 bit unsigned int while __int64 is an implementation-defined token. It's not a huge difference though.
So I should be able to use uint64_t and still typedef to u64. I'll give it a try.
absolutely, if you'd prefer to write u64, that would be the portable way to go about it :)
as a side note, the clue on all these things that aren't portable: anything that starts with a double underscore is implementation-defined.
kbhearn wrote:the point is that uint64_t from <stdint.h> is a standard-defined way to request an exactly 64 bit unsigned int while __int64 is an implementation-defined token. It's not a huge difference though.
So I should be able to use uint64_t and still typedef to u64. I'll give it a try.
absolutely, if you'd prefer to write u64, that would be the portable way to go about it
as a side note, the clue on all these things that aren't portable: anything that starts with a double underscore is implementation-defined.
Since my compiler does not come with stdint.h or inttypes.h I will just include that in the #ifdef _MSC_VER block.
If you are on a sidewalk and the covid goes beep beep
Just step aside or you might have a bit of heat
Covid covid runs through the town all day
Can the people ever change their ways
Sherwin the covid's after you
Sherwin if it catches you you're through
If you are on a sidewalk and the covid goes beep beep
Just step aside or you might have a bit of heat
Covid covid runs through the town all day
Can the people ever change their ways
Sherwin the covid's after you
Sherwin if it catches you you're through
kbhearn wrote:the point is that uint64_t from <stdint.h> is a standard-defined way to request an exactly 64 bit unsigned int while __int64 is an implementation-defined token. It's not a huge difference though.
So I should be able to use uint64_t and still typedef to u64. I'll give it a try.
absolutely, if you'd prefer to write u64, that would be the portable way to go about it :)
as a side note, the clue on all these things that aren't portable: anything that starts with a double underscore is implementation-defined.
Since my compiler does not come with stdint.h or inttypes.h I will just include that in the #ifdef _MSC_VER block.
dare i ask how old your compiler is? it's true microsoft didn't support it for a long while as it was part of C99 and microsoft didn't care about that but a few years back they finally implemented some of the core parts in VS2012 (probably at least in part because C++11 required certain C99 features to exist - the stdint.h header being one of those).
Hmm, I wonder why you need to specify __cdecl at all, not sure if it still holds for VS2015 (if would be very surprised if it wouldn't),
but __cdecl is the default calling convention (unless you mess with your project settings manually)
I also wonder why not simply int main() as you'll most likely never return anything outside -32k..32k range anyway.
I like it better.
But this is a naughty no-no:
#define EXIT_SUCCESS 1
The macro EXIT_SUCCESS is included in header file
#include <stdlib.h>
and needs to be defined by the implementation.
Believe it or not, your implementation behaves badly on {for instance} OpenVMS and normally EXIT_SUCCESS will be zero for most systems.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
mar wrote:Hmm, I wonder why you need to specify __cdecl at all, not sure if it still holds for VS2015 (if would be very surprised if it wouldn't),
but __cdecl is the default calling convention (unless you mess with your project settings manually)
I also wonder why not simply int main() as you'll most likely never return anything outside -32k..32k range anyway.
I did not try it lately, but (for instance) if you did a fastcall compile (forces things to registers for returns) you would get an error message about main() with Visual Studio. https://msdn.microsoft.com/en-us/library/6xa169sk.aspx
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
From the cited link, it looks like they fixed the problem with main():
"Using the /Gr compiler option causes each function in the module to compile as __fastcall unless the function is declared by using a conflicting attribute, or the name of the function is main."
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
Dann Corbit wrote:I did not try it lately, but (for instance) if you did a fastcall compile (forces things to registers for returns) you would get an error message about main() with Visual Studio. https://msdn.microsoft.com/en-us/library/6xa169sk.aspx
Elementary types are always returned in registers. I think fastcall simply passes function args in registers if possible (but this is done automatically for x64).
For performance critical paths tiny functions will be inlined anyway so I don't see what you really gain from using fastcall (except for adding extra ifdef/define CDECL)?
If it's not inlined (i.e. complicated) then you don't have enough registers anyway [x86] and most likely some of those args will be stored on stack anyway because you'll need to reuse registers to optimize inner loops etc.
So I would strongly discourage anyone from messing with default calling convention, it won't magically make your program run faster.