NO

Recent Posts

Pages: 1 ... 4 5 [6] 7 8 ... 10
51
Bug reports / Re: Linker Error
« Last post by Mikael on April 29, 2022, 05:00:45 pm »
OK, that actually worked! I thought I had failed to write correct prototypes to "augment" what's missing in the pre-WIN10 Windows.h, but that wasn't the problem.

To recap what I learned here:

The WIN10 SDK isn't supported out of the box, but the missing functions can still be used by doing the following:

1. Use polib to create a .lib with the missing functions.

2. Hack any needed prototypes into the code. For this example I did this:

---------------------------------------------------------------------------------------
#ifdef __POCC__
  #define WIN32_DEFAULT_LIBS
#endif
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#ifdef __POCC__
  #define WIN32_DEFAULT_LIBS
  typedef struct MEM_EXTENDED_PARAMETER {
    struct {
      DWORD64 Type;
      DWORD64 Reserved;
    } DUMMYSTRUCTNAME;
    union {
      DWORD64 ULong64;
      PVOID   Pointer;
      SIZE_T  Size;
      HANDLE  Handle;
      DWORD   ULong;
    } DUMMYUNIONNAME;
  } MEM_EXTENDED_PARAMETER, *PMEM_EXTENDED_PARAMETER;

  PVOID VirtualAlloc2(
    HANDLE                  Process,
    PVOID                   BaseAddress,
    SIZE_T                  Size,
    ULONG                   AllocationType,
    ULONG                   PageProtection,
    MEM_EXTENDED_PARAMETER *ExtendedParameters,
    ULONG                   ParameterCount
  );
#endif

---------------------------------------------------------------------------------------

So I'm back to using Pelles after all!

It's a bit of a pain to work around the missing functionality TBH, but at least I get to develop in a sensible IDE. I'll still need to make it compile on other compilers when it's done, but I won't have to do the entire development in a slow and bloated IDE that I hate...
8)

Sorry for taking up so much time, but I seriously wouldn't have sorted this out without help.
52
Bug reports / Re: Linker Error
« Last post by Pelle on April 29, 2022, 02:00:26 pm »
If I change
Code: [Select]
PAGE_NOCACHEto
Code: [Select]
PAGE_NOCACHE | PAGE_READWRITEit seems to work here...
53
Bug reports / Re: Linker Error *SOLVED*
« Last post by Mikael on April 29, 2022, 12:40:37 pm »
OK, it seems I spoke too soon...

I can now get VirtualAlloc2() to compile by adding a special .lib as instructed, but the compiler still can't find its prototype from Windows.h

I tried to work around this by writing the prototype myself, and that made it compile cleanly, but no matter what I feed the function it always returns 87 (ERROR_INVALID_PARAMETER). The problem is most likely that the Windows headers are a rat's nest of macros, so trying to work around having the correct header version is a fool's errand.

It seems to be too messy to try and use Pelles C for Windows 10 development, since it doesn't support the WIN10 SDK out of the box.

I suggest being more explicit about that - I didn't find this information anywhere, so I just assumed a compiler that supports up-to-date C on Windows would also support up-to-date Windows. Never assume anything, I guess!

It's a real pity since I love the clean simplicity of Pelles C as a development environment, but I can't afford to waste more time on this, so I'll be using MSVC instead.

Thanks for your time.
54
Beginner questions / Re: invalid directory
« Last post by John Z on April 29, 2022, 11:45:06 am »
I don't know why Pelles C still keeps creating Pelles C Projects directory on the user's Documents library (map to My Documents in user home directory). This causes so many problems! Move the Pelles C Projects directory out of the Documents library solved the problem. I suggest changing the default location of Pelles C Projects to be the user's home directory rather than the Documents library (user's My Documents).

It is just following your instructions. When you created the project you did not specify a location.  I've never had PellesC create a projects in the Document folder.  See attached image to change the project location when you create one.  It also saves this for the next one as I recall.

John Z
55
General discussions / Re: Pelles V11 Warnings
« Last post by John Z on April 29, 2022, 11:33:55 am »
I understand.  I was evidentially doing added unneeded work in the compiler optimization analysis of the code.

To clarify further - in the 'real' code all of the variables are actually used, all of that code was just stripped out to just get the smallest code to investigate the warning.

The double memset was never done in the real code, just a curiosity (what would happen if) test case.

I appreciate everyone's inputs and comments!  Always more to learn, and depth to gain.

John Z
56
The problems with Pelles C is most libraries out there doesn't support it (there is no ifdef for Pelles C at all!).
I think you put the finger on the problem right here.  But think of it in reverse.  If all compilers were compliant to the standard you would not need any ifdef for a compiler name, they all would work. 

C was imagined to be a true write once programming language.  It fails at that because of deviations from the standard in the implementations thus requiring all these exceptions partially identified by ifdef statements.  Same thing that happened in the browser wars. look how many years web developers had to battle/accomodate Micro$soft internet explorer deviations....

IMO Pelle has taken the right path and with the right goal; strict adherence to the C standards. 
 
 
John Z
57
Bug reports / Re: Linker Error *SOLVED*
« Last post by Mikael on April 28, 2022, 06:22:30 pm »
Ah, Microsoft played a little joke on us, saying a function is in one dll, then hiding it in another! :P

Anyway, I'm now free to play with all the fancy WIN10 stuff!

Thanks Timo and Pelle for the help, and for teaching me how to fix similar problems myself in the future.
58
Bug reports / Re: Linker Error (I'm fairly sure this isn't my fault!)
« Last post by Pelle on April 28, 2022, 05:58:51 pm »
Apparently VirtualAlloc2() is in kernelbase.dll, not kernel32.dll (for unknown reasons)...
59
Bug reports / Re: Linker Error (I'm fairly sure this isn't my fault!)
« Last post by Mikael on April 28, 2022, 05:11:38 pm »
Thanks TimoVJL, that almost solved the problem!  8)

I created a kernelx.lib as instructed and now the program compiles just fine.

However, when I run it I get a popup saying:

"The procedure entry point VirtualAlloc2 could not be located in the dynamic link library C:\ ... test.exe"

Any idea what I'm missing here?
60
Bug reports / Re: Linker Error (I'm fairly sure this isn't my fault!)
« Last post by TimoVJL on April 28, 2022, 04:39:51 pm »
You create your own library for it like this:
Code: [Select]
polib.exe -def:kernelx.def -out:kernelx.libkernelx.def
Code: [Select]
LIBRARY kernel32.dll
EXPORTS
VirtualAlloc2
Pages: 1 ... 4 5 [6] 7 8 ... 10