Sponsored Content
Top Forums Programming Compiler/Runtime uses of sizeof Post 302964719 by GSalisbury on Monday 18th of January 2016 12:32:45 PM
Old 01-18-2016
FWIW,
The original query was not overtly based upon concerns of overhead or performance per se but, rather, [possible?] quote technical differences in compiled result.

The illustrated fragments using sizeof as arguments were in place in an area that was already selective in execution and time and volume did not come into play.

A discussion had started on the merits of an argument vs. a variable and the posting here was more for enlarging the set of opinions. I, too, will often include additional steps etc. in order to make a sequence more clear or to be able to include some step-wise commentary.

The upshot was we (I) left the use of the sizeof as arguments in place as is principally because we (I<g>) didn't have to do anything (Management 101 - 1st precept - do nothing) and because the use was in a block that already well commented leaving no ambiguity.

Thanks.
Geo. Salisbury
Long Valley, NJ
 

9 More Discussions You Might Find Interesting

1. Programming

sizeof

we know that sizeof never returns zero when used with structure then why in this case it is returning zero struct foo { char c; }; void main() { struct foo f; cout<<sizeof(f); } i am working on solaris 5.8 isn't the above function should return the size of empty structure (7 Replies)
Discussion started by: ramneek
7 Replies

2. UNIX for Dummies Questions & Answers

xl C/C++ compiler to GCC compiler

Hi, we are converting from IBM-AIX(xl c/c++ compiler) to Linux(GCC complier). As a part of this i need to change the CFLAGS. The xl c/c++ complier CFLAGS is CFLAGS := $(CDEBUG) $(PROJECT_INCLUDE_DIRS) $(COBJECT_MODE) -qcpluscmt -qmakedep -qcheck=all \ -qalign=bit_packed $(LINT_FLAGS)... (0 Replies)
Discussion started by: pbattu1
0 Replies

3. Programming

How Can a Machine Reads a Compiler Since A Compiler is Written in Text! Not Binaries?

To make a programming language you need a compiler, so what was the first programming language and how was is created if you need the compiler first? The compiler itself is considered as a high language comparing to the machine! since the compiler is not created in 1's and 0's... Eventhough i... (12 Replies)
Discussion started by: f.ben.isaac
12 Replies

4. Programming

sizeof an array of structure without using 'sizeof' operator

Hi All, is it possible to find out the size of an array of structures ( without using 'sizeof' operator). The condition is we have the array of structure instant but we are not aware of the elements inside the structure. Can someone help me out? Thanks in advance. (18 Replies)
Discussion started by: rvan
18 Replies

5. Programming

How to get the sizeof char pointer

The below code throws the error, since the size of x = 19 is not passed to the cstrCopy function. using namespace std; static void cstrCopy(char *x, const char*y); int main () { char x; const string y = "UNIX FORUM"; cstrCopy(x,y.c_str()); return 0; } void cstrCopy(char *x,... (3 Replies)
Discussion started by: SamRoj
3 Replies

6. Programming

Doubts regarding sizeof() operator

Hi, There are some bewildering sizeof() questions I have in my mind. Could anyone shed some light on this? int main() { printf("%d\n", sizeof(main)); // Ans: 1 } That is, the sizeof() a function identifier though it is treated internally as a pointer gives 1 byte always, why? ... (5 Replies)
Discussion started by: royalibrahim
5 Replies

7. UNIX for Dummies Questions & Answers

cc compiler and gcc compiler

hi, can we install gcc compiler in unix based OS(sun solar,IBM AIX,HP,etc) and also can we install sun cc compiler in AIX environment and vice versa. and more ..is linux support cc compiler regards Ajay (3 Replies)
Discussion started by: ajaysahoo
3 Replies

8. Programming

sizeof(object) in C++

Hi, I have defined the class and call the sizeof(object to class) to get the size. # include <iostream> # include <iomanip> using namespace std; class sample { private: int i; float j; char k; public: sample() { } (2 Replies)
Discussion started by: ramkrix
2 Replies

9. Shell Programming and Scripting

Sizeof a file from directory path in perl

Hai how to find size of a file?? ex : /home/kiran/pdk/sample/calibre this is a path In that I have to find size of a files in side a calibre(it is the folder) like .results or .summary (1 Reply)
Discussion started by: kiran425
1 Replies
XtVaSetValues() 														   XtVaSetValues()

Name
  XtVaSetValues - set resource values for a widget, using varargs argument style.

Synopsis
  void XtVaSetValues(object, ..., NULL)
	   Widget object;

Inputs
  object    Specifies the object whose resources are to be modified; may be of class Object or any subclass thereof.

  ..., NULL A NULL-terminated variable-length list of resource name/value pairs to override any other resource specifications.

Availability
  Release 4 and later.

Description
  XtVaSetValues()  sets  the  resources of object named in the variable-length argument list to the values specified in the same list.	It is
  identical to XtSetValues() except that the args array of resource names and values and the num_args argument of that function are  replaced
  with a NULL-terminated variable-length argument list.

  The "Background" section below explains how to specify resource names and values in a variable-length argument list.	See XtSetValues() for
  more information on setting widget resources.

Usage
  Using variable-length argument lists is usually much more convenient than passing an ArgList which must be declared and initialized.	 Note
  that	the  varargs interface is less efficient than the ArgList interface, because each varargs function converts its argument list into an
  ArgList and calls the corresponding ArgList function.  Unless you are setting or querying resources repeatedly, however, this  overhead  is
  not generally significant.

  Variable-length  argument  lists  cannot be type-checked by the compiler, and so using XtVaSetValues() and other varargs functions can be a
  source of bugs.  Be sure to end all of your argument lists with NULL, and be sure that the type of each argument is as  expected.   If  you
  specify  only  a  single  name/value	pair  per line, it will be easy to delete or comment out resources, and to insert new resources at an
  acceptable place.

Example
  You can use XtVaSetValues() as in the following example:

     XtVaSetValues(w,
		   XtNlabel, "Enter a value:",
		   XtNjustify, XtJustifyRight,
		   XtVaTypedArg, XtNforeground, XtRString, "red", 4,
		   NULL);

Background
  This function and the other XtVa functions have resource names and values specified in a  NULL-terminated  variable-length  argument	list,
  rather  than an ArgList array.  Generally, the argument list to these functions will consist of resource names (of type String) followed by
  resource values (these are of type XtArgVal, but because varargs lists cannot be type-checked, you do not have to cast your values).	There
  are  two  special symbols which can be used in place of a resource name, however.  Each symbol modifies the interpretation of the following
  arguments.

  XtVaNestedList
    If you specify a resource name of XtVaNestedList, the following argument will be interpreted as an XtVarArgsList value,  as  returned  by
    XtVaCreateArgsList().  The resource names and values on this nested list will be treated exactly as if they were specified at the current
    point in the original list.  Nested lists may contain other nested lists, to any depth of nesting.

  XtVaTypedArg
    If you specify a resource name of XtVaTypedArg, then the following four arguments will be interpreted specially as instructions to invoke
    a  resource converter and set a resource to the result of the conversion.  The first following argument is the name of the resource to be
    set, and must be of type String.  The second following argument is also a String, the resource type of the following value.   This	type,
    plus  the  type  of  the named resource identify the resource converter to be invoked.  This argument is usually XtRString, or one of the
    other XtR types predefined by the Intrinsics.  The third following argument is the value to be converted.  It is of the type specified by
    the  previous  argument, usually a String.	If the type is not XtRString, then if the value fits in an XtArgVal, it is passed directly in
    the argument list, otherwise a pointer to the value is passed.  Finally, the forth following argument is the size in bytes of  the	type.
    If the type is XtRString, however, then type should be the length of the string plus one, not sizeof(String).

  The example above show a use of the XtVaTypedArg value.  See XtVaCreateArgsList() for an example of XtVaNestedList.

See Also
  XtSetValues(1), XtVaCreateArgsList(1).

Xt - Resource Management													   XtVaSetValues()
All times are GMT -4. The time now is 09:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy