Article View: comp.lang.c.moderated
Article #2614Coding Idioms For Functions Having External Linkage
From: Matthew Heaney
Date: Thu, 18 Apr 1996 12:30
Date: Thu, 18 Apr 1996 12:30
45 lines
1682 bytes
1682 bytes
I'm interested in learing what the C idioms are for "extern" functions. The reason I ask is because external functions have global scope, and some convention has to be established to avoid name clashes. Here is a fragment of a (bounded) stack I wrote: #ifndef BOUNDEDINTSTACK_H #define BOUNDEDINTSTACK_H typedef struct BoundedIntStackRep* BoundedIntStack; void newBoundedIntStack (int maxDepth); int topBoundedIntStack (BoundedIntStack stack); void popBoundedIntStack (BoundedIntStack stack); void pushBoundedIntStack (BoundedIntStack stack, int item); ... #endif BOUNDEDINTSTACK_H I'm interested in knowing what coding conventions a seasoned C programmer would have used to code this abstract data type. For example, do you qualify the subprograms before or after the "real" name: int topBoundedIntStack (BoundedIntStack stack); vs. int BoundedIntStackTop (BoundedIntStack stack); Would you have coded a different stack module for each kind of native type? Or just use a BoundedLongStack for all integer types (letting the compiler automatically coerce the item into type long)? Steve Summit gave a recommendation in his book on how to code an abstract data type. Steve: is the example I provided what you had in mind? matt
Technical Details
Message-ID:
<4l5clc$1tm@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: mheaney@ni.net (Matthew Heaney) Newsgroups: comp.lang.c.moderated Subject: Coding Idioms For Functions Having External Linkage Date: 18 Apr 1996 07:30:36 -0500 Organization: Estormza Software Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4l5clc$1tm@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com