When compiling the following code to study the execv() system call, I get
the compilation error for exit() shown below.
I'm using ssh from home to access my university Unix console. I was
thinking that maybe the firewall or my access privileges may be the problem.
Can someone please explain.
#include <unistd.h>
main()
{
char * const av[]={"ls","-l",(char *)0};
execv("/bin/ls", av);
perror("execv failed");
exit(1);
}
runls2.c: In function âmainâ:
runls2.c:8: error: syntax error before numeric constant
runls2.c:9: warning: incompatible implicit declaration of built-in function
âexitâ 7 2973
On Sun, 15 Jul 2007 14:32:03 +1000, "Peter"
<pe********@opt usnet.com.auwro te:
> When compiling the following code to study the execv() system call, I get
I wonder what kind of function execv is that it takes a system command
twice but that is a completely different issue.
>the compilation error for exit() shown below.
I'm using ssh from home to access my university Unix console. I was thinking that maybe the firewall or my access privileges may be the problem.
Where do you come up with these off the wall assumptions.
A hard lesson every new programmer has to learn is that the compiler
is correct a lot more often than you are. No, compilers are not
perfect. But, when they issue a diagnostic, your first reaction
should be "What in my code is causing it to complain?"
> Can someone please explain.
#include <unistd.h>
main() {
char * const av[]={"ls","-l",(char *)0};
The third expression would be more meaningful if written as NULL.
Did you really mean for the elements of av to be constant pointers to
(non-constant) char? Is that the type of argument execv really
expects?
>
execv("/bin/ls", av);
perror("execv failed");
exit(1); }
runls2.c: In function âmainâ: runls2.c:8: error: syntax error before numeric constant runls2.c:9: warning: incompatible implicit declaration of built-in function âexitâ
Because you did not include stdlib.h, there is no prototype in scope
for exit. A C89 compiler must assume that exit returns an int. But
your compiler knows that exit returns void. If you lie to the
compiler, expect it to get upset. At least this time it warned you at
compile time rather than generating code that would confuse you at
execution time.
While you are at it, include stdio.h for perror also.
Remove del for email
On Jul 15, 12:32 am, "Peter" <petesbl...@opt usnet.com.auwro te:
When compiling the following code to study the execv() system call, I get
the compilation error for exit() shown below.
I'm using ssh from home to access my university Unix console. I was
thinking that maybe the firewall or my access privileges may be the problem.
I seriously doubt it.
Can someone please explain.
#include <unistd.h>
main()
'int main (void)' is better
{
char * const av[]={"ls","-l",(char *)0};
execv("/bin/ls", av);
perror("execv failed");
you need to '#include <stdio.h>' to use perror.
exit(1);
you need to '#include <stdlib.h>' to use exit.
>
}
runls2.c: In function âmainâ:
runls2.c:8: error: syntax error before numeric constant
runls2.c:9: warning: incompatible implicit declaration of built-in function
âexitâ
The compiler output does not seem to match the code you provided: you
should have received a warning about the implicit declaration of
perror and the line before the call to exit() (presumably line 8) is
empty so the error doesn't make sense. Make the changes mentioned
above, if you still have an issue make sure you copy and paste the
exact program along with the complete output from the compiler.
Robert Gamble
Barry Schwarz <sc******@doezl .netwrites:
On Sun, 15 Jul 2007 14:32:03 +1000, "Peter"
<pe********@opt usnet.com.auwro te:
>>When compiling the following code to study the execv() system call, I get
I wonder what kind of function execv is that it takes a system command
twice but that is a completely different issue.
<OT>
The first argument is the file name of the program to be executed.
The second and successive arguments are the initial values for argv
in the newly executed program.
</OT>
Because of this (and other system dependencies), you can't assume that
the value of argv[0] necessarily has anything to do with the actual
name of the program.
[...]
>>#include <unistd.h>
main() { char * const av[]={"ls","-l",(char *)0};
The third expression would be more meaningful if written as NULL.
Did you really mean for the elements of av to be constant pointers to
(non-constant) char? Is that the type of argument execv really
expects?
<OT>Yes.</OT>
[snip]
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
"Peter" <pe********@opt usnet.com.auwri tes:
[...]
#include <unistd.h>
main()
{
char * const av[]={"ls","-l",(char *)0};
execv("/bin/ls", av);
perror("execv failed");
exit(1);
}
runls2.c: In function âmainâ:
runls2.c:8: error: syntax error before numeric constant
runls2.c:9: warning: incompatible implicit declaration of built-in function
âexitâ
The line numbers and error messages do not match the code you posted.
There are errors in your code, but I don't see anything that would be
considered a syntax error.
When you post code here, always copy-and-paste the *exact* code that
you actually compiled. We can't possibly guess which errors are in
your original code, and which you introduced when you re-typed it.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
On Sun, 15 Jul 2007 12:20:33 -0700, in comp.lang.c , Keith Thompson
<ks***@mib.orgw rote:
>The line numbers and error messages do not match the code you posted.
Do you remember the VMS debugger, which included all your headers in
the line-numbering, so the canonical hello world programme had 2000+
lines....
--
Mark McIntyre
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Op Sun, 15 Jul 2007 22:30:47 +0100 schreef Mark McIntyre:
On Sun, 15 Jul 2007 12:20:33 -0700, in comp.lang.c , Keith Thompson
<ks***@mib.orgw rote:
>>The line numbers and error messages do not match the code you posted.
Do you remember the VMS debugger, which included all your headers in
the line-numbering, so the canonical hello world programme had 2000+
lines....
What about
cc -E hello.c | wc
;-)
--
Coos
On Mon, 16 Jul 2007 00:11:35 +0200, in comp.lang.c , Coos Haak
<ch*****@hccnet .nlwrote:
>Op Sun, 15 Jul 2007 22:30:47 +0100 schreef Mark McIntyre:
>On Sun, 15 Jul 2007 12:20:33 -0700, in comp.lang.c , Keith Thompson <ks***@mib.org wrote:
>>>The line numbers and error messages do not match the code you posted.
Do you remember the VMS debugger, which included all your headers in the line-numbering, so the canonical hello world programme had 2000+ lines....
What about
cc -E hello.c | wc
The fun part with VMS was working out which line was the one you
wanted... eg 2241 in the below output from the C debugger on
OpenVMS7.3 (trimmed for linelength and compiled 2 minutes ago... )
$ r test
hello world
%SYSTEM-F-ACCVIO, access violation, reason mask=04
%TRACE-F-TRACEBACK, symbolic stack dump follows
module name routine name line
TEST main 2241
$ type test.c
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char *p;
printf("hello world\n");
strcpy(p, "bar");
return 0;
}
--
Mark McIntyre
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jim Patterson |
last post by:
I am trying to compile php with sablotron and I get this error message
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
xslt_set_object function
=====================================================================
make: *** Error 1
|
by: Adam McCarthy |
last post by:
I'm trying to get a cross compiler working for arm-wince-pe. This is
the output for the primes Pyrex example. If I compile simple Hello,
World's etc, it works fine, but for some reason Python
libraries/headers seem to produce this. I have libpython2.3.a in
/usr/local/lib/gcc-lib/arm-wince-pe/3.3.3/../../../../arm-wince-pe/lib/
and /usr/lib/python2.3/config. I've checked it using
arm-wince-pe-objdump. I also extracted it with...
|
by: Jean-David Beyer |
last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2
V6.1 (with all the FixPacks) on my old machine.
I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat
Enterplise Linux 3 ES, and applied FixPack fp5_mi00069.tar to it. After
creating an instance, starting the database, creating a database, and
entering the table definitions, all of which seems to work OK, I entered a
tiny 8-row table and can do...
|
by: Wayne |
last post by:
The following which is driving me nuts has occurred in 2 of my
databases. Both databases were written in Access 2003 and then
converted back to Access 2000 format. I've done this so I can create an
Access 2K mde for compatibility reasons.
Everything worked fine: the database could be compiled and converted to
an .mde several times. Then for no apparent reason when I tried to
compile again I got the following error: "Compile Error: Can't...
|
by: JS |
last post by:
I use winXP and have installed Cygwin. I use Dev-C++ and the Cygwin
compiler, but for some reason I can't compile this code:
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
typedef int othread_t;
| |
by: electrixnow |
last post by:
Help!,
I need to compile this code with static libs so it run on another XP
machine that does'nt have
MS Studio installed. When I compile now I get an ERROR:
1>------ Rebuild All started: Project: drawing_control, Configuration:
Release Win32 ------
1>Deleting intermediate and output files for project 'drawing_control',
configuration 'Release|Win32'
|
by: baur79 |
last post by:
# python configure.py -q
/usr/lib/qt-3.3/
This is the GPL version of PyQt 3.16 (licensed under the GNU General
Public
License) for Python 2.4.2 on linux2.
Type 'L' to view the license.
Type 'yes' to accept the terms of the license.
Type 'no' to decline the terms of the license.
|
by: akhilesh.noida |
last post by:
I am trying to compile glibc-2.5 for ARM based board. But I am getting
errors while configuring it. Please check and give your inputs for
resolving this.
configure command :
$ ../glibc-2.5/configure --prefix=/mnt/new/Mars/glibc_HQ_test/GLIBC/
install/ --with-__thread
--enable-kernel=2.6.11 --enable-shared
|
by: myusernotyours |
last post by:
Hi All,
Am working on a Java application in which I have to use the JNI to Interface with some native code for both windows and unix. Am using netbeans IDE with the C/C++ pack installed. Am also using Cygwin as my compiler (gcc), this is ostensibly because I hope this compiler will also compile the unix native libraries since I don't have a Linux installation. (I am working on a personal project from the office and can't get linux installed)....
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |