Sponsored Content
Top Forums Programming Parameter passing to function with void * as Argument Post 302902991 by rupeshkp728 on Friday 23rd of May 2014 11:10:22 AM
Old 05-23-2014
Quote:
Originally Posted by Corona688
Did you try the code or just consider it to look wrong...? Why?

The whole point of using a union, and the whole point of adding type to the beginning of your CS and DS structures, was that they'd all have the same memory layout.

The compiler warns you since it doesn't know you built with these assumptions in mind. You can avoid the warning with a typecast if you want:

Code:
myfunc((S *)&obj);

ok that is fine
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Passing Argument to Function

May i know how to pass an argument to a function in a shell script? Sorry, i din stated that it is in a shell script in my previous post. Means: checkStatus() { ........... } read status; I wanna use the status in the function checkstatus, how... (2 Replies)
Discussion started by: AkumaTay
2 Replies

2. Shell Programming and Scripting

Passing a string parameter to a function

I need to pass a parameter to a function in a script. My parameter is a string. When I display the parameter within my function, I only get the first word from string I pass in. How can I make the function receive the whole string (and not terminate at the first space it encounters)?. part of... (1 Reply)
Discussion started by: fastgoon
1 Replies

3. UNIX for Advanced & Expert Users

Parameter passing in a function

I need to pass a parameter to a function in a script. My parameter is a string. When I display the parameter within my function, I only get the first word from string I pass in. How can I make the function receive the whole string (and not terminate at the first space it encounters)?. part of... (2 Replies)
Discussion started by: fastgoon
2 Replies

4. Programming

How to return void function pointer

Hello all im trying to build function that will return void function pointer what is mean is ( not working ) the main function void * myClass::getFunction(int type){ if(type==1) return &myClass::Test1; if(type==2) return &myClass::Test2; } void myClass::Test1(){... (1 Reply)
Discussion started by: umen
1 Replies

5. Shell Programming and Scripting

Passing more than one argument in a function

Hi All, Calling a function with one argument and storing the return value in a shell script is as below:( so far I know) value="`fun_1 "argument1"`" Its working perfectly for me. Can u help me with passing more than one argument and storing the return value Thnaks in advance JS (1 Reply)
Discussion started by: jisha
1 Replies

6. Shell Programming and Scripting

Passing commandline argument to a function

Hi, I have 2 ksh scripts. Script1.ksh contains function definition. script1.ksh function f1() { while getopts a:c: args do case $args in a) ARG1=$OPTARG ;; c) ARG2=$OPTARG ;; \?) echo "Error no valid Arguments passed" esac done echo $ARG1 echo $ARG2 script2.sh (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

7. Shell Programming and Scripting

Passing sql as parameter to unix function

Hi, I have a function which connects to the db and runs the sql. it works fine when I run it like: function "select empname from emp;" but when I try to pass the sql string to a variable which in turn in fed to the function , it throws error. please advise. Thanks, Arnie. (1 Reply)
Discussion started by: itsarnie
1 Replies

8. Shell Programming and Scripting

passing argument from one function to another

Hi all, In the given script code . I want to pass the maximum value that variable "i" will have in function DivideJobs () to variable $max of function SubmitCondorJob(). Any help? Thanks #!/bin/bash ... (55 Replies)
Discussion started by: nrjrasaxena
55 Replies

9. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

10. Shell Programming and Scripting

Passing command as a function parameter

Hi All, Just trying to implement the below shell script using AIX ksh shell. myfunc { eval "$*" } CMD='ls -la /etc/hosts | awk '{print $9"|"$5}'' myfunc $CMD Keeping getting "|}: not found" errors, any pointers would greatly be appreciated. Kind Regards Ed Please... (2 Replies)
Discussion started by: eo29
2 Replies
2C(1)							      General Commands Manual							     2C(1)

NAME
2c, 6c, 8c, kc, vc, xc - C compilers SYNOPSIS
2c [ option ... ] [ file ... ] 6c [ option ... ] [ file ... ] 8c [ option ... ] [ file ... ] kc [ option ... ] [ file ... ] vc [ option ... ] [ file ... ] xc [ option ... ] [ file ... ] DESCRIPTION
2c, 6c, 8c, kc, vc, and xc compile the named C files into MC68020, i960, i386, SPARC, MIPS, and ATT3210 object files. The compilers handle most preprocessing directives themselves; a complete preprocessor is available in cpp(1), which must be run separately. Let the first letter of the compiler name be O= 2, 6, 8, k, v, or x. The output object files end in .O. The letter is also the prefix of related programs: Oa is the assembler, Ol is the loader. Associated with each compiler is a string objtype= 68020, 960, 386, sparc, mips, or 3210. Plan 9 conventionally sets the $objtype environment variable to the objtype string appropriate to the current machine's type. Plan 9 also conventionally has /objtype directories, which contain among other things: include, for machine-dependent include files; lib, for public object code libraries; bin, for public programs; and mkfile, for preconditioning mk(1). The compiler options are: -o obj Place output in file obj (allowed only if there is just one input file). Default is to take the last element of the input file name, strip any trailing .c, and append .O. -w Print warning messages about unused variables, etc. -B Accept functions without a new-style ANSI C function prototype. By default, the compilers reject functions used without a defined prototype, although ANSI C permits them. -Dname=def -Dname Define the name to the preprocessor, as if by If no definition is given, the name is defined as -Idir An file whose name does not begin with slash or is enclosed in double quotes is always sought first in the directory of the file argument. If this fails, or the name is enclosed in <>, it is then sought in directories named in -I options, then in /sys/include, and finally in /$objtype/include. -N Suppress automatic registerization and optimization. -S Print an assembly language version of the object code on standard output as well as generating the .O file. -a Instead of compiling, print on standard output acid functions (see acid(1)) for examining structures declared in the source files. -aa Like -a except suppress information about structures declared in included header files. The compilers support several extensions to ANSI C: - A structure or union may contain unnamed substructures and subunions. The fields of the substructures or subunions can then be used as if they were members of the parent structure or union (the resolution of a name conflict is unspecified). When a pointer to the outer structure or union is used in a context that is only legal for the unnamed substructure, the compiler promotes the type and adjusts the pointer value to point at the substructure. If the unnamed structure or union is of a type with a tag name specified by a typedef statement, the unnamed structure or union can be explicitly referenced by <struct variable>.<tagname>. - A structure value can be formed with an expression such as (struct S){v1, v2, v3} where the list elements are values for the fields of struct S. - Array initializers can specify the indices of the array in square brackets, as int a[] = { [3] 1, [10] 5 }; which initializes the third and tenth elements of the eleven-element array a. - Structure initializers can specify the structure element by using the name following a period, as int struct { int x; int y; } s = { .y 1, .x 5 }; which initializes elements y and then x of the structure s. - A global variable can be dedicated to a register by declaring it extern register in all modules and libraries. - A #pragma of the form #pragma lib "libbio.a" records that the program needs to be loaded with file /$objtype/lib/libbio.a; such lines, typically placed in library header files, obviate the -l option of the loaders. To help identify files in non-standard directories, within the file names in the #pragmas the string $M represents the name of the architecture (e.g., mips) and $O represents its identifying character (e.g., v). - The C++ comment (// to end of line) is accepted as well as the normal convention of /* */. - The compilers accept long long variables as a 64-bit type. The standard header typedefs this to vlong. The vlong runtime is slow. EXAMPLE
For the 68020, produce a program prog from C files main.c and sub.c: 2c -w main.c sub.c 2l -o prog main.2 sub.2 FILES
/sys/include system area for machine-independent #include directives. /$objtype/include system area for machine-dependent #include directives. SOURCE
/sys/src/cmd/cc machine-independent part /sys/src/cmd/2c, etc. machine-dependent part SEE ALSO
2a(1), 2l(1), cpp(1), mk(1), nm(1), pcc(1), db(1), acid(1), Rob Pike, ``How to Use the Plan 9 C Compiler'' BUGS
The i960 compiler has been used only to program one I/O controller and is certainly buggy. The preprocessor only handles and For a full ANSI preprocessor, use cpp(1) on the files first. 2C(1)
All times are GMT -4. The time now is 02:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy