473,382 Members | 1,258 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

1)preprocessor warning ,2) argv[0]..btw, my first mail to clc :-)

hi all,
two doubts
1) in this code.. one might pass FUNC(x) definition externally..

#ifdef FUNC(x)
double fnew(double x){
return FUNC(x);
}
#endif

but i get a warning..(things work nice though)
=>warning: extra tokens at end of #ifdef directive

why is it so.. and how can one get rid of this..

2) I was wondering if it was possible to change argv[0] during
runtime.. so that
he process table show the newname rather than say "a.out"
OR is it OSdependent
PS:.. c.l.c is cool !

Jan 22 '06 #1
2 1842
vinayby a écrit :
1) in this code.. one might pass FUNC(x) definition externally..

#ifdef FUNC(x)
double fnew(double x){
return FUNC(x);
}
#endif
This is incorrect. You want

#ifdef FUNC
double fnew(double x)
{
return FUNC(x);
}
#endif

assuming that the FUNC() macro is defined before.
2) I was wondering if it was possible to change argv[0] during
runtime...
Yes, it is.

Just be careful what your are doing. argv points to an array of pointers
to char. You can decide to make argv[0] point elsewhere:

argv[0] = "My smart name";

but don't use strcpy(),

strcpy(argv[0], "My smart name"); /* WRONG! */

because you know nothing about the space pointetd by argv[0].
he process table show the newname rather than say "a.out"
OR is it OSdependent


What about giving your executable a better name ? Read your
compiler/lnker documentation for details.

--
A+

Emmanuel Delahaye
Jan 22 '06 #2
Emmanuel Delahaye wrote:
vinayby a écrit :

<snip>
2) I was wondering if it was possible to change argv[0] during
runtime...


Yes, it is.

Just be careful what your are doing. argv points to an array of pointers
to char. You can decide to make argv[0] point elsewhere:

argv[0] = "My smart name";

but don't use strcpy(),

strcpy(argv[0], "My smart name"); /* WRONG! */

because you know nothing about the space pointetd by argv[0].


This is wrong. One may change argv as it is not const-qualified
and one may change the strings pointed to by argv[i], i < argc,
because the standard allows it. So, snprintf() or strncpy()
restricted by the original length of the string pointed to by
argv[0] is the right answer.
See the thread starting at
<11**********************@g49g2000cwa.googlegroups .com>
for a detailled discussion.
he process table show the newname rather than say "a.out"
OR is it OSdependent


This is not necessarily possible. argv[0] may point to a copy
of the name at the start of the program.
So, OS dependent means are probably necessary.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Jan 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Irmen de Jong | last post by:
Hi I'm trying to create e-mail content using the email.MIMEText module. It basically works, until I tried to send mail in non-ascii format. What I did, to test both iso-8859-15 and UTF-8...
3
by: aaj | last post by:
SQL SERVER 2000 Hi all This is my first attempt at writing a stored procedure. I have managed to get it working but its unlikely to be the best way of handling the problem. While writing it I...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
9
by: -Nacho- | last post by:
Hi all I have a table with some email addresses of a mailing list subscribers. I'm triying to send a mail to them by querying the table and sending the mail from a 'while' loop, but I only get...
10
by: amygdala | last post by:
Hi all, Another problem that has been bugging me for a while now, but which I swept under the rug too long too now is a mail encoding problem at my (shared) webhost. The problem is that on...
22
Geeza1973
by: Geeza1973 | last post by:
Below is the code I have: <?php include("db.php"); mysql_connect ($host, $user, $pass); mysql_select_db ($database); $result = mysql_query ("SELECT * FROM `highscore` ORDER BY score DESC LIMIT...
5
by: John Boyd | last post by:
I know I can post to page 2 but the problem is I need to capture the name, email (optional), and referral source. If i post to page 2 then it simply asks for the required fields. If I do get it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.