Sponsored Content
Full Discussion: Dump program variables
Top Forums UNIX for Advanced & Expert Users Dump program variables Post 17697 by AtleRamsli on Tuesday 19th of March 2002 12:37:39 PM
Old 03-19-2002
To do this the way you state it is only possible if you use the symbol table, and you do not want to use a debugging tool as part of your program :-)

You should put all your globals into a struct, and then read and write that struct.

lets say you have a name, and some int, and a float:
Code:
int GL_i;
char GL_name[256];
float GL_f;

Change this to:
Code:
struct {
	int i;
	char name[256];
	float f;

} GL;

As a rule, if you have lots of globals spread out like in the first example, your program is badly structured.
A global is a potential bug.
For every global, contemplate making it static.
For the structure above, contemplate storing it in a dynamically allocated buffer - you will win big: You can have multiple instances, and your program (or library) will become safer, for a library this may provide reentrancy (each instance has its own data - or you will have to lock it!)

Atle

Last edited by vbe; 02-01-2020 at 01:18 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

help, what is the difference between core dump and panic dump?

help, what is the difference between core dump and panic dump? (1 Reply)
Discussion started by: aileen
1 Replies

2. UNIX for Dummies Questions & Answers

Dummie: How do I get variables mid program

I'm writing a simple program in unix and was wondering how mid switch I can run a program and get someone to enter variables for it i.e.: #!/bin/csh -f echo "If you wish to do v press v" echo "If you wish to compile press c" echo "If you wish to add an entry press a" echo "If you wish to... (1 Reply)
Discussion started by: RichardB
1 Replies

3. Shell Programming and Scripting

Passing shell variables to awk program..

Hello, Can we pass shell variables like $PATH etc. to a awk program part for example, awk ' { fieldValue=$PATH .... }' file (1 Reply)
Discussion started by: Vishnu
1 Replies

4. Shell Programming and Scripting

How to access the C program variables in shell script

hi I wanted to access the C program variables in shell script. This script is called from the same C program. What are the ways in which i can access variables thankx (3 Replies)
Discussion started by: bhakti
3 Replies

5. Shell Programming and Scripting

problem accessing Multiple Variables from C Program to a Shell script

program name--test #!/bin/bash output1=`/home/user/a.c` output2=`/home/user/a.c` k=`$output1 + 1` m=`$output2 + 1` echo $k echo $m --------------------------------------------------------------------------- prgram name--a.c #include<stdio.h> int main() (1 Reply)
Discussion started by: sameworld1980
1 Replies

6. UNIX for Dummies Questions & Answers

Small Program with variables

Hello Geniuses of the unix world. please help, stupid chemist. I have the following script that I need to create a file. Doesnt make sense unless i explain this way: I need to create a file called summary.in I would like all these lines to be inserted however in the command line I would like the... (1 Reply)
Discussion started by: gingburg
1 Replies

7. Shell Programming and Scripting

Is there a command to close a program with dump?

I'm running into some problems using pkill in my scripts. I'm using a program that needs to dump. (4 Replies)
Discussion started by: ninjaaron
4 Replies

8. UNIX for Dummies Questions & Answers

I am not able to use variables in system command in a C program

this method is not working.I am having a problem to use variables in system command. i cannot use the variables in system command. this how i was did system("whereis command"); this method works very fine. but, i want use the commands as variable. that means i want only pass the variables.... (6 Replies)
Discussion started by: dhanda2601
6 Replies

9. UNIX Desktop Questions & Answers

Knowing the size and location of variables in a C program

So I need some help with this. Pardon me if I'm posting in the wrong forum, after some googling for my answer and finding nothing I found this forum. It seemed appropriate for what I was seeking. I just didnt find a forum that concerned the use of GDB. I'm learning to use the C language and GDB.... (2 Replies)
Discussion started by: Cambria
2 Replies

10. Shell Programming and Scripting

Using env variables to run a program

Hi there, I need urgent help with a small program that is run via shell script. Unfortunately I only understand the bare basics of shell scripting and can't figure out how to do this. We have a program that tests the connection between 3 servers. I have a script that lets the program run on... (15 Replies)
Discussion started by: Pherdinand
15 Replies
globals(3U)						    InterViews Reference Manual 					       globals(3U)

NAME
globals - Unidraw global constants, types, instances, and functions. SYNOPSIS
#include <Unidraw/globals.h> DESCRIPTION
Several constants and types are used throughout the Unidraw library. It also provides global access to one-of-a-kind instances such as the unidraw object as well as shared graphics resources. Finally, there are several global functions for common data manipulations. All of these are declared one file for inclusion into other files where they are needed. CONSTANTS
static const int CHARBUFSIZE Size of standard character buffer. static const int HANDLE_SIZE Size of selection handles, in pixels. static const char MARK[] String that delineates data boundaries in the ASCII representation that Catalog generates. Used for error checking. static const int PIN_RAD The radius of a pin, used in its default graphical representation, in pixels. static const int SLOP Tolerance within which a hit on a graphical object will be detected, in pixels. TYPES
enum DragConstraint Enumerates orthogonal ways in which cursor movement may be constrained, usually during direct manipulation. Possible values include None, XFixed, YFixed, XYEqual, HorizOrVert, or Gravity. enum Mobility Enumerates the three possible component mobilities: Fixed, Floating, or Undef (undefined). typedef unsigned Orientation Specifies two kinds of orientation: Portrait or Vertical (synonymous), and Landscape or Horizontal (synonymous). enum TransMethod Enumerates the three possible transmission methods for connectors: In, Out, or InOut. typedef unsigned long ClassId Type for representing unique class names for catalog-managed objects. INSTANCES
extern Unidraw* unidraw extern CSolver* csolver The global unidraw and csolver objects. These and all other global instances are initialized automatically. extern PSColor* psblack extern PSColor* pswhite extern PSPattern* pssolid extern PSPattern* psclear extern PSPattern* psnonepat extern PSBrush* pssingle extern PSBrush* psnonebr extern PSFont* psstdfont Predefined graphics resource objects. The None operation on psnonepat and psnonebr returns true. extern Graphic* stdgraphic A FullGraphic instance with its graphics state set to the global values listed above, excluding psnonepat and psnonebr. FUNCTIONS
extern void NormalRect(Coord& l, Coord& b, Coord& r, Coord& t) Given two coordinate pairs (l, b) and (r, t), it checks whether l < r and b < t. If not, it swaps the values in the offending inequalities. This function is useful for ensuring that a rectangle is defined by its lower-left and upper-right vertices. extern void GetLine( const char* buf, int len, int beg, int& end, int& size, int& nextBeg ) This function is convenient for extracting lines from a buffer with a minimum of additional math operations. Given a buffer of char- acters buf of length len, search for the first newline character (or the last character in the buffer) after the character at index beg; return the newline's position in end, the size of the run of text terminated by a newline (end + 1 - beg), and the index with which to begin a search for the next newline character (nextBeg). extern void GetAlignmentPoint( Graphic*, Alignment, float&, float& ) Return the point (in floating point canvas coordinates) on a graphic corresponding to the given alignment. For example, to obtain the coordinates of the lower-left of a rectangle graphic, specify the graphic and a BottomLeft alignment. extern void Ref(Resource*) Call the Reference operation on the given instance of a resource subclass if the pointer is non-nil. extern char* strnew(const char*) Duplicate the given null-terminated string, creating a buffer of the appropriate size and returning the null-terminated result. SEE ALSO
CSolver(3U), Catalog(3U), Graphic(3U), GraphicView(3U), Pin(3U), Resource(3I), Unidraw(3U), InterViews(3I), pspaint(3U) Unidraw 30 July 1990 globals(3U)
All times are GMT -4. The time now is 01:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy