News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Understanding C structures

Started by jj2007, August 24, 2016, 12:44:27 AM

Previous topic - Next topic

TWell

with cl.exe -E someone could clean header a bit. int __cdecl _vscprintf(    const char * _Format, va_list _ArgList);
  int __cdecl _snprintf_c(  char * _DstBuf,   size_t _MaxCount,     const char * _Format, ...);
  int __cdecl _vsnprintf_c(  char *_DstBuf,   size_t _MaxCount,     const char * _Format, va_list _ArgList);

  int __cdecl _fprintf_p(   FILE * _File,     const char * _Format, ...);
  int __cdecl _printf_p(    const char * _Format, ...);
  int __cdecl _sprintf_p(    char * _Dst,   size_t _MaxCount,     const char * _Format, ...);
  int __cdecl _vfprintf_p(   FILE * _File,     const char * _Format, va_list _ArgList);
  int __cdecl _vprintf_p(    const char * _Format, va_list _ArgList);
  int __cdecl _vsprintf_p(    char * _Dst,   size_t _MaxCount,     const char * _Format, va_list _ArgList);
  int __cdecl _scprintf_p(    const char * _Format, ...);
  int __cdecl _vscprintf_p(    const char * _Format, va_list _ArgList);

jj2007

Interesting! What exactly does that do?

https://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx
/E  Copies preprocessor output to standard output.
/EP  Copies preprocessor output to standard output.

adeyblue

Quote
Interesting! What exactly does that do?
It evaluates the files according to the command line defines and outputs a resulting .i (text) file so it doesn't contain any pragmas, defines, macros, comments or anything the actual C compiler doesn't need. The difference between /E and /EP is one outputs certain file and line numbers and the other doesn't. You can also add /C to retain the comments.
For instance if you don't have UNICODE defined, you'll get a file full of all the A prototypes and structs, and none of the W ones (except the W only functions).

If stuff actually worked properly, /Zg would dump function prototypes. Except it seems a bit crippled in that it only outputs the last/a random 5 from each include. It's also been removed from the 2015 and above versions.

jj2007

Quote from: adeyblue on September 19, 2016, 06:13:52 AMIt evaluates the files according to the command line defines and outputs a resulting .i (text) file

Sample attached.

Quote from: adeyblue on September 19, 2016, 06:13:52 AMIf stuff actually worked properly, /Zg would dump function prototypes.

VC 2010 Express:
Quote1>------ Rebuild All started: Project: PlainWin32, Configuration: Debug Win32 ------
1>cl : Command line warning D9035: option 'Zg' has been deprecated and will be removed in a future release
1>  Main.cpp
1>c1xx : fatal error C1048: unknown option 'g' in '-Zg'

Microsoft at its best :eusa_boohoo:

But this looks actually promising, option /EP:1>  ULONGLONG
1>  __stdcall
1>  Int64ShllMod32 (
1>       ULONGLONG Value,
1>       DWORD ShiftCount
1>      );
1> 
1>  LONGLONG
1>  __stdcall
1>  Int64ShraMod32 (
1>       LONGLONG Value,
1>       DWORD ShiftCount
1>      );
1> 


There are over 3000 of them:1>  __stdcall/1>  Int64ShllMod32 (
1>  __stdcall/1>  Int64ShraMod32 (
1>  __stdcall/1>  Int64ShrlMod32 (
1>  __stdcall/1>  Int64ShllMod32 (
1>  __stdcall/1>  Int64ShraMod32 (
1>  __stdcall/1>  Int64ShrlMod32 (
1>  __stdcall/1>  EXCEPTION_ROUTINE (
1>  __stdcall/1>  RtlUnwind (
1>  __stdcall/1>  RtlInitializeSListHead (
1>  __stdcall/1>  RtlFirstEntrySList (
1>  __stdcall/1>  RtlInterlockedPopEntrySList (
1>  __stdcall/1>  RtlInterlockedPushEntrySList (
1>  __stdcall/1>  RtlInterlockedFlushSList (
1>  __stdcall/1>  RtlQueryDepthSList (
1>  __stdcall/1>  RTL_RUN_ONCE_INIT_FN (
1>  __stdcall/1>  RtlRunOnceInitialize (
1>  __stdcall/1>  RtlRunOnceExecuteOnce (
1>  __stdcall/1>  RtlRunOnceBeginInitialize (
1>  __stdcall/1>  RtlRunOnceComplete (
1>  __stdcall/1>  RtlCaptureStackBackTrace(
1>  __stdcall/1>  RtlCaptureContext (
1>  __stdcall/1>  RtlCompareMemory (


Problem is there are only about 3,000 (with #include <windows.h>), while there are about 15,000 in \masm32\include ::)

jj2007

Good news - Redmond tries to make the CRT simpler:
QuoteThe CRT provides 142 different variations of printf ... This 2,696 line file had 223 conditionally compiled regions of code (#ifdef, #else, etc.)

Reminds me of the famous Edsger Dijkstra quote:
Quote
It is practically impossible to teach good programming to students that have had a prior exposure to C++: as potential programmers they are mentally mutilated beyond hope of regeneration.

hutch--


MichaelW

https://msdn.microsoft.com/en-us/library/cc230322.aspx

Quote
A DWORD_PTR is an unsigned long type used for pointer precision. It is used when casting a pointer to an unsigned long type to perform pointer arithmetic. DWORD_PTR is also commonly used for general 32-bit parameters that have been extended to 64 bits in 64-bit Windows.
Well Microsoft, here's another nice mess you've gotten us into.

rrr314159

Quote from: jj2007 on September 28, 2016, 12:49:39 AM
Reminds me of the famous Edsger Dijkstra quote:
Quote
It is practically impossible to teach good programming to students that have had a prior exposure to C++: as potential programmers they are mentally mutilated beyond hope of regeneration.

IMHO if you need a teacher to show you how to code, you never had much potential in the first place.
I am NaN ;)

hutch--

> IMHO if you need a teacher to show you how to code, you never had much potential in the first place.  :P