linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* #define-s for clarity/convenience
@ 2007-06-23  6:23 Shriramana Sharma
  0 siblings, 0 replies; only message in thread
From: Shriramana Sharma @ 2007-06-23  6:23 UTC (permalink / raw)
  To: Linux C Programming List

[-- Attachment #1: Type: text/plain, Size: 317 bytes --]

Hello.

I enclose herewith some #define-s I created for clarity. They are in the 
public domain to be used if anyone finds them useful.

I also request the experienced programmers here to share any such 
#define-s they may have. I and others may benefit. Please also specify 
the terms for usage.

Shriramana Sharma.

[-- Attachment #2: jamadagni.h --]
[-- Type: text/x-chdr, Size: 3091 bytes --]

// (c) Shriramana Sharma, 2007. Placed in the public domain by the author.
// version 2, 2007-06-23

//
// some replacements using # define for ambiguous/pitfall/unclear/related keywords/operators in C++ for convenience
// it would be nice if the following replacements (even with other replacers) were to be part of a future C++ standard
// the current usages can be supported with deprecated status
//

//
// in the following comments, "declaration" also means "implicitly declaring definition" unless stated otherwise
//

//--------
// static
//--------

// "local" for "static" in declarations of variables and functions at file scope which are desired to be visible only in the current translation unit
# define local static

// "sticky" for "static" in declarations of local variables inside a function which should retain their value between function calls
# define sticky static

// "classwide" for "static" in declarations of local variables inside a class which are common to all instances of that class
# define classwide static

// "nothis" for "static" in declarations of member functions inside a class which can be called without an instance of that class
# define nothis static

//--------
// extern
//--------

// "exists" for "extern" in pure declarations (no implictly declaring definitions) of variables, types and functions which are defined elsewhere
# define exists extern
// in a future standard if "exists" is used in an implicitly declaring definition it should be an error
// if there is no "exists" in a line declaring a variable then it means memory should be allocated for that variable; if there is "exists", then no memory is allocated

// "global" for "extern" in declarations of variables and functions which are desired to be visible across all translation units; complement to "local" above
# define global extern
// this may of course be omitted since it is the default
// in a future version of GCC implementing a future standard, when "global" is used in an implicitly declaring definition there should be no warning -- currently GCC warns when "extern" is used here

// "decorateas" for "extern" to enclose declarations of functions which must be decorated in a particular way - i.e. "C" or "C++"
# define decorateas extern

//
// other:
//

// "pure" for "= 0" for declarations of pure virtual functions in classes
// since pure virtual means no definition exists, the word declarations here above does not include implicitly declaring definitions
# define pure = 0
// in a future standard preferably the word "pure" can be written before "virtual" instead of at the end of the declaration as provided by this # define

//---
// &
//---

// "ref" for "&" in declarations of variables and functions to denote a reference
# define ref &

// "addr" for "&" for extracting the address of a variable or function
# define addr(X) & X

//---
// *
//---

// "ptr" for "*" in declarations of variables and functions to denote a pointer
# define ptr *

// "ptee()" for "*" for dereferencing pointers; ptee = pointee, just as ptr = pointer
# define ptee(X) * X

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-06-23  6:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-23  6:23 #define-s for clarity/convenience Shriramana Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).