Hey everyone. So I'm looking at a few C programming resources, and it seems, by convention how you should write and define a function, is first declare it's existence before your main...then call it somewhere in your main, and then define after, at the end of the program? Is this necessary? I mean can't you declare AND define it in one block of code before your main function? So...
instead of splitting it up :
It just seems easier to declare and define it all in one step before you even get to the main funtion rather than save it's definition for the end of the code?
in the header file orville.h, outside of the #ifdef #endif , there is the following
#define JOB_CONTROL /* support job-control */
As you can see, the JOB_CONTROL macro has no value associated with it. Here is what I go when I ran grep on the entire source code.
$ grep -iR... (6 Replies)
Hi friends,
I am not sure if perl questions can be raised here. :rolleyes:
But I have a doubt if there is a way to do "#define" in perl, like in C.
Does anyone know if it is feasible (without CPAN modules)?
Thanks,
Srini (7 Replies)
Hello,
I would like to conditionaly comment in my code source some fields from arrays. So I use the property ## from the #define definition.
my code:
...
#define slet /##*
#define etsl *##/
...
const T_SVT_ADLL_A653_DESC A_DESC =
{
{ slet qwerty etsl SLICING,... (3 Replies)
if i do this in C
#define NUM 1234512345
then how come i cant print it out using
int main(int argc, char **argv) {
printf("%d\n", NUM);
return 0;
}
well the result is -1219236538, why isnt it 1234512345 ? (7 Replies)
I have 7 functions those need to be executed as command line inputs, I tried with below code it’s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line
if
then... (8 Replies)
HI
I have file A.txt
_1A
_2A
_3A
_4A
I want define all as different variable.
$1A=_1A
$2B=_2A
$3C=_3A
$4D=_4A
Now i can use any variable in my script. (3 Replies)
Hi,
I just define the variable in script and use those script in another script but the variable not recognize.
test1.sh
#!/bin/bash
DB="test_db"
USR="test_user"
PWD="test_pwd"
HST="24.254.87.12"
test2.sh
#!/bin/bash
./test1.sh
mysql -u $USR -p $PWD -h $HST... (2 Replies)
Discussion started by: fspalero
2 Replies
LEARN ABOUT HPUX
xtoffsetof
XtOffsetOf() XtOffsetOf()
Name
XtOffsetOf - determine the byte offset of a field within a structure type.
Synopsis
Cardinal XtOffsetOf(structure_type, field_name)
Inputs
structure_type
Specifies a type that is declared as a structure.
field_name
Specifies the name of a field of the structure.
Returns
The offset in bytes of the specified field from the beginning of the specified structure.
Availability
Release 4 and later.
Description
XtOffsetOf() is a macro that expands to a constant expression that gives the offset in bytes to the specified structure member from the
beginning of the structure.
Usage
XtOffset() is usually used to determine the location of an variable within a structure when initializing a resource list. It is used by
widget writers, and anyone who needs to fetch application resources with XtGetApplicationResources(). Resource fields are defined in terms
of offsets from a base address from the beginning of a widget. Thus, a resource value can be kept up to date by the Resource Manager with-
out any knowledge of the instance structure of the widget; it uses just a relative byte offset.
XtOffsetOf() is slightly more portable than XtOffset() which performs the same function but takes a pointer type rather than a structure
type.
Example
XtOffsetOf() is used to declare a resource list for the Athena Label widget:
#define offset(field) XtOffsetOf(LabelRec, field)
static XtResource resources[] = {
{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
offset(label.foreground), XtRString, XtDefaultForeground},
{XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
offset(label.font),XtRString, XtDefaultFont},
.
.
Background
XtOffsetOf() is defined in terms of XtOffset() on many systems:
#ifdef offsetof
#define XtOffsetOf(s_type,field) offsetof(s_type,field)
#else
#define XtOffsetOf(s_type,field) XtOffset(s_type*,field)
#endif
See AlsoXtOffset(1).
Xt - Utilities XtOffsetOf()