Let's say it simple and concise:
don't use macro. Never.
edit: bold
The preprocessor, skilfully used, enables extreme portability of code between very different systems, while keeping the main body of the code compact and readable.
As to Pascal, I think it was missing a bit too much - at least in its original form - to be really usable for anything either moderately complex (it didn't have separate compilation or modules!), or moderately low-level. Not just a matter of preprocessor here. So in the early 70's, not sure Pascal would have been able to "compete" even if it got a preprocessor.
Later variants of Pascal got a lot more features, so that's a different story. But it was too late.
I had Hitech C on my ZX Spectrum back in 1984.
DiTBho: no need to shout.
As for the advice itself: you don’t have any choice. Not unless you want to stop using any library, including the C standard library.
Disagree.
I am 100% convinced that the preprocessor is THE reason that hacky ugly C won out over functionally-equivalent but more "pure" languages such as Pascal.
but that doesn't mean it's bad or should be avoided at all costs.
DiTBho: no need to shout.
As for the advice itself: you don’t have any choice. Not unless you want to stop using any library, including the C standard library.
... or build a massive NIH cathedral with new C standard library, complete tooling, even compilers written from scratch or modified ("hacked"), then make this a company policy, so that maybe 5-10 people on the Earth follow this new C-like language, which doesn't even allow * and & for pointer syntax but replaces it with something else. Then start filling threads giving others advice based on this internal paradigm, 98% of the time completely "forgetting" to mention this has nothing to do with normal C, causing massive confusion to everyone.
In other words, I applaud complex and interesting custom solutions; complete descriptions thereof even more; but I hate games like this.
both gcc and clang have the -E option.
I am using windows 10 operating system.
I'm so sorry.QuoteWhat is command for winows
If you use gcc or clang, then the same as anywhere else.
I don't know if there are versions of gcc and clang that work in the DOS command line -- probably -- but you can certainly use them if you install WSL or cygwin.
I believe Mingw-w64 is a port of gcc that can create Windows applications. I'm not sure whether it runs under DOS or in cygwin etc.
#include<stdio.h>
#define add(y) ((y) + 1)
int main ()
{
int y = 5;
printf("y = %d ", add(y));
return 0;
}
# 1 "hello.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "hello.c"
# 1 "c:\\mingw\\include\\stdio.h" 1 3
# 38 "c:\\mingw\\include\\stdio.h" 3
# 39 "c:\\mingw\\include\\stdio.h" 3
# 56 "c:\\mingw\\include\\stdio.h" 3
# 1 "c:\\mingw\\include\\_mingw.h" 1 3
# 55 "c:\\mingw\\include\\_mingw.h" 3
# 56 "c:\\mingw\\include\\_mingw.h" 3
# 66 "c:\\mingw\\include\\_mingw.h" 3
# 1 "c:\\mingw\\include\\msvcrtver.h" 1 3
# 35 "c:\\mingw\\include\\msvcrtver.h" 3
# 36 "c:\\mingw\\include\\msvcrtver.h" 3
# 67 "c:\\mingw\\include\\_mingw.h" 2 3
# 1 "c:\\mingw\\include\\w32api.h" 1 3
# 35 "c:\\mingw\\include\\w32api.h" 3
# 36 "c:\\mingw\\include\\w32api.h" 3
# 59 "c:\\mingw\\include\\w32api.h" 3
# 1 "c:\\mingw\\include\\sdkddkver.h" 1 3
# 35 "c:\\mingw\\include\\sdkddkver.h" 3
# 36 "c:\\mingw\\include\\sdkddkver.h" 3
# 60 "c:\\mingw\\include\\w32api.h" 2 3
# 74 "c:\\mingw\\include\\_mingw.h" 2 3
# 57 "c:\\mingw\\include\\stdio.h" 2 3
# 69 "c:\\mingw\\include\\stdio.h" 3
# 1 "c:\\mingw\\lib\\gcc\\mingw32\\6.3.0\\include\\stddef.h" 1 3 4
# 216 "c:\\mingw\\lib\\gcc\\mingw32\\6.3.0\\include\\stddef.h" 3 4
# 216 "c:\\mingw\\lib\\gcc\\mingw32\\6.3.0\\include\\stddef.h" 3 4
typedef unsigned int size_t;
# 328 "c:\\mingw\\lib\\gcc\\mingw32\\6.3.0\\include\\stddef.h" 3 4
typedef short unsigned int wchar_t;
# 357 "c:\\mingw\\lib\\gcc\\mingw32\\6.3.0\\include\\stddef.h" 3 4
typedef short unsigned int wint_t;
# 70 "c:\\mingw\\include\\stdio.h" 2 3
# 94 "c:\\mingw\\include\\stdio.h" 3
# 1 "c:\\mingw\\include\\sys/types.h" 1 3
# 34 "c:\\mingw\\include\\sys/types.h" 3
# 35 "c:\\mingw\\include\\sys/types.h" 3
# 62 "c:\\mingw\\include\\sys/types.h" 3
typedef long __off32_t;
typedef __off32_t _off_t;
typedef _off_t off_t;
# 91 "c:\\mingw\\include\\sys/types.h" 3
typedef long long __off64_t;
typedef __off64_t off64_t;
# 115 "c:\\mingw\\include\\sys/types.h" 3
typedef int _ssize_t;
typedef _ssize_t ssize_t;
# 95 "c:\\mingw\\include\\stdio.h" 2 3
# 1 "c:\\mingw\\lib\\gcc\\mingw32\\6.3.0\\include\\stdarg.h" 1 3 4
# 40 "c:\\mingw\\lib\\gcc\\mingw32\\6.3.0\\include\\stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 103 "c:\\mingw\\include\\stdio.h" 2 3
# 210 "c:\\mingw\\include\\stdio.h" 3
typedef struct _iobuf
{
char *_ptr;
int _cnt;
char *_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
} FILE;
# 239 "c:\\mingw\\include\\stdio.h" 3
extern __attribute__((__dllimport__)) FILE _iob[];
# 252 "c:\\mingw\\include\\stdio.h" 3
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * fopen (const char *, const char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * freopen (const char *, const char *, FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fflush (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fclose (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int remove (const char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int rename (const char *, const char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * tmpfile (void);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) char * tmpnam (char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) char *_tempnam (const char *, const char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _rmtmp (void);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _unlink (const char *);
# 289 "c:\\mingw\\include\\stdio.h" 3
__attribute__((__cdecl__)) __attribute__((__nothrow__)) char * tempnam (const char *, const char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int rmtmp (void);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int unlink (const char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int setvbuf (FILE *, char *, int, size_t);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) void setbuf (FILE *, char *);
# 342 "c:\\mingw\\include\\stdio.h" 3
extern int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__mingw_printf__,2,3))) __mingw_fprintf(FILE*, const char*, ...);
extern int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__mingw_printf__,1,2))) __mingw_printf(const char*, ...);
extern int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__mingw_printf__,2,3))) __mingw_sprintf(char*, const char*, ...);
extern int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__mingw_printf__,3,4))) __mingw_snprintf(char*, size_t, const char*, ...);
extern int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__mingw_printf__,2,0))) __mingw_vfprintf(FILE*, const char*, __builtin_va_list);
extern int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__mingw_printf__,1,0))) __mingw_vprintf(const char*, __builtin_va_list);
extern int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__mingw_printf__,2,0))) __mingw_vsprintf(char*, const char*, __builtin_va_list);
extern int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__mingw_printf__,3,0))) __mingw_vsnprintf(char*, size_t, const char*, __builtin_va_list);
# 376 "c:\\mingw\\include\\stdio.h" 3
extern unsigned int _mingw_output_format_control( unsigned int, unsigned int );
# 453 "c:\\mingw\\include\\stdio.h" 3
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fprintf (FILE *, const char *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int printf (const char *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int sprintf (char *, const char *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int vfprintf (FILE *, const char *, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int vprintf (const char *, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int vsprintf (char *, const char *, __builtin_va_list);
# 478 "c:\\mingw\\include\\stdio.h" 3
int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__ms_printf__,2,3))) __msvcrt_fprintf(FILE *, const char *, ...);
int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__ms_printf__,1,2))) __msvcrt_printf(const char *, ...);
int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__ms_printf__,2,3))) __msvcrt_sprintf(char *, const char *, ...);
int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__ms_printf__,2,0))) __msvcrt_vfprintf(FILE *, const char *, __builtin_va_list);
int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__ms_printf__,1,0))) __msvcrt_vprintf(const char *, __builtin_va_list);
int __attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__ms_printf__,2,0))) __msvcrt_vsprintf(char *, const char *, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _snprintf (char *, size_t, const char *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _vsnprintf (char *, size_t, const char *, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _vscprintf (const char *, __builtin_va_list);
# 501 "c:\\mingw\\include\\stdio.h" 3
__attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__mingw_printf__,3,4)))
int snprintf (char *, size_t, const char *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) __attribute__((__format__(__mingw_printf__,3,0)))
int vsnprintf (char *, size_t, const char *, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__))
int vscanf (const char * __restrict__, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__))
int vfscanf (FILE * __restrict__, const char * __restrict__, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__))
int vsscanf (const char * __restrict__, const char * __restrict__, __builtin_va_list);
# 646 "c:\\mingw\\include\\stdio.h" 3
__attribute__((__cdecl__)) __attribute__((__nothrow__)) ssize_t
getdelim (char ** __restrict__, size_t * __restrict__, int, FILE * __restrict__);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) ssize_t
getline (char ** __restrict__, size_t * __restrict__, FILE * __restrict__);
# 666 "c:\\mingw\\include\\stdio.h" 3
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fscanf (FILE *, const char *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int scanf (const char *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int sscanf (const char *, const char *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fgetc (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) char * fgets (char *, int, FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fputc (int, FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fputs (const char *, FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) char * gets (char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int puts (const char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int ungetc (int, FILE *);
# 687 "c:\\mingw\\include\\stdio.h" 3
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _filbuf (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _flsbuf (int, FILE *);
extern inline __attribute__((__gnu_inline__)) __attribute__((__cdecl__)) __attribute__((__nothrow__)) int getc (FILE *);
extern inline __attribute__((__gnu_inline__)) __attribute__((__cdecl__)) __attribute__((__nothrow__)) int getc (FILE * __F)
{
return (--__F->_cnt >= 0)
? (int) (unsigned char) *__F->_ptr++
: _filbuf (__F);
}
extern inline __attribute__((__gnu_inline__)) __attribute__((__cdecl__)) __attribute__((__nothrow__)) int putc (int, FILE *);
extern inline __attribute__((__gnu_inline__)) __attribute__((__cdecl__)) __attribute__((__nothrow__)) int putc (int __c, FILE * __F)
{
return (--__F->_cnt >= 0)
? (int) (unsigned char) (*__F->_ptr++ = (char)__c)
: _flsbuf (__c, __F);
}
extern inline __attribute__((__gnu_inline__)) __attribute__((__cdecl__)) __attribute__((__nothrow__)) int getchar (void);
extern inline __attribute__((__gnu_inline__)) __attribute__((__cdecl__)) __attribute__((__nothrow__)) int getchar (void)
{
return (--(&_iob[0])->_cnt >= 0)
? (int) (unsigned char) *(&_iob[0])->_ptr++
: _filbuf ((&_iob[0]));
}
extern inline __attribute__((__gnu_inline__)) __attribute__((__cdecl__)) __attribute__((__nothrow__)) int putchar(int);
extern inline __attribute__((__gnu_inline__)) __attribute__((__cdecl__)) __attribute__((__nothrow__)) int putchar(int __c)
{
return (--(&_iob[1])->_cnt >= 0)
? (int) (unsigned char) (*(&_iob[1])->_ptr++ = (char)__c)
: _flsbuf (__c, (&_iob[1]));}
# 734 "c:\\mingw\\include\\stdio.h" 3
__attribute__((__cdecl__)) __attribute__((__nothrow__)) size_t fread (void *, size_t, size_t, FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) size_t fwrite (const void *, size_t, size_t, FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fseek (FILE *, long, int);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) long ftell (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) void rewind (FILE *);
# 787 "c:\\mingw\\include\\stdio.h" 3
typedef long long fpos_t;
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fgetpos (FILE *, fpos_t *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fsetpos (FILE *, const fpos_t *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int feof (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int ferror (FILE *);
# 808 "c:\\mingw\\include\\stdio.h" 3
__attribute__((__cdecl__)) __attribute__((__nothrow__)) void clearerr (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) void perror (const char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * _popen (const char *, const char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _pclose (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * popen (const char *, const char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int pclose (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _flushall (void);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _fgetchar (void);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _fputchar (int);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * _fdopen (int, const char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _fileno (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _fcloseall (void);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * _fsopen (const char *, const char *, int);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _getmaxstdio (void);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _setmaxstdio (int);
# 859 "c:\\mingw\\include\\stdio.h" 3
unsigned int __attribute__((__cdecl__)) __mingw_get_output_format (void);
unsigned int __attribute__((__cdecl__)) __mingw_set_output_format (unsigned int);
int __attribute__((__cdecl__)) __mingw_get_printf_count_output (void);
int __attribute__((__cdecl__)) __mingw_set_printf_count_output (int);
# 885 "c:\\mingw\\include\\stdio.h" 3
extern inline __attribute__((__gnu_inline__)) __attribute__((__always_inline__)) unsigned int __attribute__((__cdecl__)) _get_output_format (void)
{ return __mingw_get_output_format (); }
extern inline __attribute__((__gnu_inline__)) __attribute__((__always_inline__)) unsigned int __attribute__((__cdecl__)) _set_output_format (unsigned int __style)
{ return __mingw_set_output_format (__style); }
# 910 "c:\\mingw\\include\\stdio.h" 3
extern inline __attribute__((__gnu_inline__)) __attribute__((__always_inline__)) int __attribute__((__cdecl__)) _get_printf_count_output (void)
{ return 0 ? 1 : __mingw_get_printf_count_output (); }
extern inline __attribute__((__gnu_inline__)) __attribute__((__always_inline__)) int __attribute__((__cdecl__)) _set_printf_count_output (int __mode)
{ return 0 ? 1 : __mingw_set_printf_count_output (__mode); }
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fgetchar (void);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fputchar (int);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * fdopen (int, const char *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fileno (FILE *);
# 930 "c:\\mingw\\include\\stdio.h" 3
extern inline __attribute__((__gnu_inline__)) __attribute__((__always_inline__)) FILE * __attribute__((__cdecl__)) __attribute__((__nothrow__)) fopen64 (const char *, const char *);
extern inline __attribute__((__gnu_inline__)) __attribute__((__always_inline__))
FILE * __attribute__((__cdecl__)) __attribute__((__nothrow__)) fopen64 (const char * filename, const char * mode)
{ return fopen (filename, mode); }
int __attribute__((__cdecl__)) __attribute__((__nothrow__)) fseeko64 (FILE *, __off64_t, int);
extern inline __attribute__((__gnu_inline__)) __attribute__((__always_inline__)) __off64_t __attribute__((__cdecl__)) __attribute__((__nothrow__)) ftello64 (FILE *);
extern inline __attribute__((__gnu_inline__)) __attribute__((__always_inline__))
__off64_t __attribute__((__cdecl__)) __attribute__((__nothrow__)) ftello64 (FILE * stream)
{ fpos_t __pos; return (fgetpos(stream, &__pos)) ? -1LL : (__off64_t)(__pos); }
# 958 "c:\\mingw\\include\\stdio.h" 3
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fwprintf (FILE *, const wchar_t *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int wprintf (const wchar_t *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int vfwprintf (FILE *, const wchar_t *, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int vwprintf (const wchar_t *, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _snwprintf (wchar_t *, size_t, const wchar_t *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _vscwprintf (const wchar_t *, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _vsnwprintf (wchar_t *, size_t, const wchar_t *, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fwscanf (FILE *, const wchar_t *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int wscanf (const wchar_t *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int swscanf (const wchar_t *, const wchar_t *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wint_t fgetwc (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wint_t fputwc (wchar_t, FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wint_t ungetwc (wchar_t, FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int swprintf (wchar_t *, const wchar_t *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int vswprintf (wchar_t *, const wchar_t *, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wchar_t * fgetws (wchar_t *, int, FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int fputws (const wchar_t *, FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wint_t getwc (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wint_t getwchar (void);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wint_t putwc (wint_t, FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wint_t putwchar (wint_t);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wchar_t * _getws (wchar_t *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _putws (const wchar_t *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * _wfdopen(int, const wchar_t *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * _wfopen (const wchar_t *, const wchar_t *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * _wfreopen (const wchar_t *, const wchar_t *, FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * _wfsopen (const wchar_t *, const wchar_t *, int);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wchar_t * _wtmpnam (wchar_t *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wchar_t * _wtempnam (const wchar_t *, const wchar_t *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _wrename (const wchar_t *, const wchar_t *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _wremove (const wchar_t *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) void _wperror (const wchar_t *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * _wpopen (const wchar_t *, const wchar_t *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int snwprintf (wchar_t *, size_t, const wchar_t *, ...);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int vsnwprintf (wchar_t *, size_t, const wchar_t *, __builtin_va_list);
# 1016 "c:\\mingw\\include\\stdio.h" 3
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int vwscanf (const wchar_t *__restrict__, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__))
int vfwscanf (FILE *__restrict__, const wchar_t *__restrict__, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__))
int vswscanf (const wchar_t *__restrict__, const wchar_t * __restrict__, __builtin_va_list);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) FILE * wpopen (const wchar_t *, const wchar_t *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wint_t _fgetwchar (void);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wint_t _fputwchar (wint_t);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _getw (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int _putw (int, FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wint_t fgetwchar (void);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) wint_t fputwchar (wint_t);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int getw (FILE *);
__attribute__((__cdecl__)) __attribute__((__nothrow__)) int putw (int, FILE *);
# 2 "hello.c" 2
# 4 "hello.c"
int main ()
{
int y = 5;
printf("y = %d ", ((y) + 1));
return 0;
}
what should be observed in this text file
Disagree.
I am 100% convinced that the preprocessor is THE reason that hacky ugly C won out over functionally-equivalent but more "pure" languages such as Pascal.
Your opinion, bus sorry, I don't agree with that.
For me, C flexibility with "data-struct" and "data-union" coupled with more powerful "pointer arithmetic" is one of *THE* reason whey C is better than Pascal in this specific cases
Ok, I made the mistake to quickly test them with what I had on my hands, but why are you still here reproach me it was somehow confusing? and can't I express what I honestly think from 25 years of professional programming experience?
Pascal has records, variant records, pointers, and the ability to cast between integers and pointers and find the size of objects. It has *exactly* the same capabilities as C in those regards.
What is "professional", exactly?
Pascal has records, variant records, pointers, and the ability to cast between integers and pointers and find the size of objects. It has *exactly* the same capabilities as C in those regards.
Pascal was my first programming language, and I know in TurboPascal v7 there is no "cast" feature which does this in the compile process like C. In Turbo Pascal there are standard procedures (built-in, or external) which *convert* a type to another type.
The standard functions Ord and Ptr provide direct control of the
address contained in a pointer. Ord returns the address contained in
its pointer argument as an Integer, and Ptr converts its Integer
argument into a pointer which is compatible with all pointer types.
These functions are extremely valuable in the hands of an experienced
programmer as they allow a pointer to point to anywhere in memory.
If used carelessly, however, they are very dangerous, as a dynamic
variable may be made to overwrite other variables, or even program
code.
Syntax: Addr(Name);
Returns the address in memory of the first byte of the type, varialbe,
procedure, or function with the identifier Name. If Name is an array, it
may be subscripted, and if Name is a record, specific fields may be
selected. The value returned is of type Integer.
Syntax: SizeOf(Name);
Returns the number of bytes occupied in memory by the variable or
type Name. The result is of type Integer.
var
s : array[1..11] of char;
p : ^char;
begin
s := 'Hello World';
p := Ptr(Addr(s) + 6 * SizeOf(char));
WriteLn(p^);
end
The only thing I was really missing in Pascal was the ability to pass functions and procedures as parameters/variables. (I think that was added in TP much later?)
Of course, Wirth added that in Oberon (and maybe Modula, but I admit I don't know Modula well.)
But still there's a lot confusion
QuoteThe standard functions Ord and Ptr provide direct control of the address contained in a pointer. Ord returns the address contained in its pointer argument as an Integer, and Ptr converts its Integer argument into a pointer which is compatible with all pointer types.
OType = (type1, type2, type3);
OMe = record
case myType: OType of <-------------- this is a union-like in Pascal
type1: (w1: Integer);
type2: (w2: Integer);
type3: (w3: Integer);
end;
var
O: OMe;
begin
O.myType := Type1;
O.w2 := 666; <-------- There is no w2 for Type1, w2 belongs to Type2!
end.
- ISO 7185 Standard Pascal implementations usually care about that#define pool_N 200
pool_item_t pool[pool_N];
#define Ver "v1.0"
#define Rev "revA"