Sponsored Content
Top Forums Programming Some questions regarding old if.c Post 302930433 by achenle on Sunday 4th of January 2015 01:41:56 AM
Old 01-04-2015
Quote:
Originally Posted by ongoto
I meant no offense.
I'm just going along with what you said. The questions you raised supports the fact that it doesn't make any sense, right?

if (exp()) is asking if the function exists; it's not calling that function.
...
The more I think about it, the less sure I am about that. As K&R C treats pretty much all functions as variable-argument, how could the compiler know what you meant? There's no way for a compiler to know if you're doing an existence check which would simply evaluate to the address of the function, or call the function with zero arguments.

I think there's a good chance that code that you identified actually does make the call to exp(), with unknown data on the stack. I think to just check if the function exists, the code would be if ( exp ).

Either way, anyone who writes code like that without comments on WHAT is being done is being incompetent, in my opinion.

When you go out into the esoteric edges of a programming language like that, even you are likely to not remember exactly what you did later on. And everyone else who didn't write the code is almost certainly going to be stumped for a good bit. Production or library code is not the place to compete in obscure coding ego wars.

And I freely admit that calling a vararg function with zero arguments makes no sense - with undefined junk on the stack, there's no way to know what would happen. That's another reason the code should be commented. To figure out what exactly is going on requires breaking out the C standard and maybe even hardware-specific behavior because "putting variables on the stack" is highly hardware-specific.
This User Gave Thanks to achenle For This Post:
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

i got some questions :)

Hi! Im new to all this but the computer club im in has unix i think. now my questions. 1.is it NTFS i need to partion the harddrive with to be able to use unix? 2.Unix and Linux whats the diffrense?yes im a noob got no idea been using crap windows for ages and hate it. 3.I got a win98... (2 Replies)
Discussion started by: Pierre
2 Replies

2. Programming

C questions

What does "extern" do? ex. extern int x; and another question, what about using static in functions? like: static void foo(), why? (2 Replies)
Discussion started by: Esaia
2 Replies

3. Solaris

2 Questions

Hello Everbody I hope you can give me a hand, I have some questions The first one itīs about some message that I donīt know what means, I was looking about it. but nothing. This is the message rsh: connection from bad port bsd-gw: Error reading from connection: Bad file number And my... (4 Replies)
Discussion started by: lo-lp-kl
4 Replies

4. UNIX for Dummies Questions & Answers

Just a few questions.

Hi everyone im new to this forums, i just wanted to get started by asking a few question(Im a Unix newbie) 1. How do i sort a file called "dirr" in a ascending order on the 3rd column 2. what does alias on=who do Thanks in advance!!! (1 Reply)
Discussion started by: Da Paper
1 Replies

5. Programming

two questions

hey all, I have question when am writing simple shell... in the child am calling execvp, i want the parent to know when execvp returns - 1. how can i let the parent know the result of execvp thanks in advance (9 Replies)
Discussion started by: joey
9 Replies

6. Homework & Coursework Questions

Print questions from a questions folder in a sequential order

1.) I am to write scripts that will be phasetest folder in the home directory. 2.) The folder should have a set-up,phase and display files I have written a small script which i used to check for the existing users and their password. What I need help with: I have a set of questions in a... (19 Replies)
Discussion started by: moraks007
19 Replies

7. UNIX for Dummies Questions & Answers

Just had a few questions

1) The lpr and sort utilities accept input either from a file named on the command line or from standard input. a)Name two other utilities that function in a similar manner. b)Name a utility that accepts its input only from standard input. 2) Explain the following error message. What... (10 Replies)
Discussion started by: youngyou
10 Replies

8. UNIX for Dummies Questions & Answers

Vi questions

Hello, I would like to know how we can highlight/select a section of a file in vi and delete that section if we don't want to use the dd command to delete one line at at time. There is one where we don't want to delete the whole line , but up to a certain word. (2 Replies)
Discussion started by: Pouchie1
2 Replies
_stack_grow(3C) 					   Standard C Library Functions 					   _stack_grow(3C)

NAME
_stack_grow - express an intention to extend the stack SYNOPSIS
#include <ucontext.h> void *_stack_grow(void *addr); DESCRIPTION
The _stack_grow() function indicates to the system that the stack is about to be extended to the address specified by addr. If extending the stack to this address would violate the stack boundaries as retreived by stack_getbounds(3C), a SIGSEGV is raised. If the disposition of SIGSEGV is SIG_DFL, the process is terminated and a core dump is generated. If the application has installed its own SIGSEGV handler to run on the alternate signal stack, the signal information passed to the handler will be such that a call to stack_viola- tion(3C) with these parameters returns 1. The addr argument is a biased stack pointer value. See the Solaris 64-bit Developer's Guide. This function has no effect if the specified address, addr, is within the bounds of the current stack. RETURN VALUES
If the _stack_grow() function succeeds and does not detect a stack violation, it returns addr. ERRORS
No errors are defined. USAGE
The _stack_grow() function does not actually adjust the stack pointer register. The caller is responsible for manipulating the stack pointer register once _stack_grow() returns. The _stack_grow() function is typically invoked by code created by the compilation environment prior to executing code that modifies the stack pointer. It can also be used by hand-written assembly routines to allocate stack-based storage safely. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
stack_getbounds(3C), stack_inbounds(3C), stack_violation(3C), attributes(5) Solaris 64-bit Developer's Guide SunOS 5.10 18 Jul 2002 _stack_grow(3C)
All times are GMT -4. The time now is 02:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy