Are there any compilers where you can over align members in a struct (other than the first member)? GCC has __attribute__(aligned(x)) but I'm not sure if that can be applied to the struct members....
Type: Posts; User: MOS-6581
Are there any compilers where you can over align members in a struct (other than the first member)? GCC has __attribute__(aligned(x)) but I'm not sure if that can be applied to the struct members....
"f" is a string. Use 'f' if you want a single char.
Callbacks are function pointers: The Function Pointer Tutorials - Index
What will actually happen if I compile my library with GCC (64 bit) and then use MSVC to compile the calling code? Let's replace short with long in the above function and assume that we're compiling...
What if you're providing a shared library or a DLL for a particular platform though? You have no control over what compiler the user might be using. I've never seen any requirements that you have to...
I thought about this some more and now I have even more doubts. What happens if the basic data types aren't the same size as in the compiler that was used to compile the shared library? For example,...
I was hoping for a solution that would work with at least all the major compilers like GCC, Clang and VC++. I looked at the #pragma pack directive but that doesn't seem 100% reliable since the...
I want to make a shared library that exposes structs and unions that aren't just opaque pointers. Is this portable at all between compilers on the same platform or should I change the design...
You usually never deal with DLL files directly in your code. You can manually load and unload DLLs if you want to but that is usually done by the linker when you compile your project (in Visual...
What do you mean "per desktop"? I read somewhere that each process has it's own lookup table for classes where the HINSTANCE of the module is one field in the table. Something like this:
Module ...
Replace the function signature like this:
int makeBet(char *choice, int *num)
You can then call the function like this:
char choice;
int num;
makeBet(&choice, &num);
You're only printing the values in dice1.
It seems that I had the wrong idea about how window class registration in Windows works. The window class you register in a DLL is not shared by all processes that use the DLL so you only need to...
I still haven't found a solution to this problem. This is the documentation for the RegisterClass function:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633587(v=vs.85).aspx
This...
Non-static local variables only occupy memory when the function is running since they are allocated on the stack. You should be concerned about stack overflow though if you're allocating huge arrays.
Check the return value from fwrite and see if you get any errors.
You can statistically analyze files to determine the encoding but it's not 100% reliable or something you should do yourself. The best way to do it is to just read the file as it is and then have the...
Why do a lot of professors insist on using old and outdated software and language standards? Is it because they don't want to put any effort in staying up to date? I would've complained about the...
Post your code. It could be an issue with endianness or similar.
It's a bug that happens when you post code here.
Your file system is most likely case sensitive. Have you tried "valgrind" instead of "Valgrind"?
What's the alternative to fread if you just want to read sizeof(wchar_t) bytes at a time?
I did some testing myself and found some strange results that I can't explain. I first created a simple file in Notepad with the text "Hello" and then saved it as "Unicode". Windows reports that the...
Show the entire code. Don't forget to check the return value from functions. It's possible that WideCharToMultiByte is failing for some reason. It returns 0 if it failed.
Keep in mind that there's not a one-to-one mapping between UTF-8 and UTF-16. A character encoded as UTF-16 can take up more or less bytes when converted to UTF-8. To obtain the correct size of the...