-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dear Everyone,
I was had this pointed out to me, by Simon Perreault <nomis80(a)nomis80.org>
(with my reply):
"On Saturday 27 Dec 2003 8:49 pm, you wrote:
> 1) Please do not cross-post. (This means sending the same message to many
> lists.)
OK, guilty, but I wanted a varied response, as different people subscribe to
different lists.
>
> 2) Please stay on topic. This has nothing to do with Fedora.
Fedora is GNU/Linux, there are C programmers, like you that use Fedora, and it
is a general discussion list. What's the problem? I'm not asking for money
for for you to join some crazy scheme.
This kind of attitude annoys me about GNU/Linux, I am not wasting anyones
time, so I don't see what the problem is."
And his last reply:
"On December 27, 2003 16:11, you wrote:
> This kind of attitude annoys me about GNU/Linux, I am not wasting anyones
> time, so I don't see what the problem is.
Yes, you are wasting time (and bandwidth, as there are some people on very
slow connections) when you are not on topic. This list is not even about
GNU/Linux, it is about Fedora. General Linux questions do not belong here.
This is Fedora-related stuff only. There are tons of Linux and C mailing
lists.
This is a quick lesson (that everyone must learn, I did too) on netiquette.
You should Google a bit on that topic, particularly on stuff related to
mailing lists."
I am sorry if I have wasted everyones time and bandwidth, but I have spent the
last 3 days searching for up to date links and book reviews, some things you
never find, like the website: http://www.accu.org/bookreviews/public/
recommended by another user.
I admit, I have cross posted, as I not only use Fedora, but Debian, SUSE and
Gentoo. These are all different distro's with different user bases. I wanted
to get a good feel of what are good texts from all the C programmers out
their. I didn't get a response like above from anyone else. Even Alan Cox
replied to me.
What I don't understand is, and I quote, "This list is not even about
GNU/Linux, it is about Fedora."
What is Fedora then?
Again, sorry to waste everyones time, but you have all helped me out.
- --
Regards
http://www.magicfx.co.ukhttp://www.suretecsystems.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/7f0YgNqd7Kng8UoRAimuAKCikZFb2yBGtrHss8AWHmb7pPwQMwCg4OAT
hiT3sr0rPLJBLtQl/uiqQOU=
=mTvq
-----END PGP SIGNATURE-----
Hi,
I'm trying to learn glade. autogen.sh failed on my first try; giving the error
below:
./configure: line 4068: syntax error near unexpected token `PACKAGE,'
./configure: line 4068: `PKG_CHECK_MODULES(PACKAGE, $pkg_modules)'
Then i learned that i had to install pkgconfig; i did so; but this time
autogen gave the following error:
checking for gtk+-2.0 >= 2.0.0... Package gtk+-2.0 was not found in the
pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
configure: error: Library requirements (gtk+-2.0 >= 2.0.0) not met; consider
adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a
nonstandard prefix so pkg-config can find them.
How do i have to set PKG_CONFIG_PATH environment variable?
Thanks in advance.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all,
During my degree, BEng (Hons) Electronics and Communications Engineering, we
did C programming every year, but I never kept it up, as I had no interest
and didn't see the point. But now I really want to get back into it as I see
a point with GNU/Linux. I want to get my old skills back and write something
or help on some projects etc.
I need some good books. I used to have one called "A Book On C", but sold it,
and I have been reading various tutorials on the web and the many devoted
websites.
Anyone have any recommendations?
One more question, should I go for C or C++? Which will benefit me more with
GNU/Linux?
Thanks for your time,
Gavin.
- --
Regards
http://www.magicfx.co.ukhttp://www.suretecsystems.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/7e1UgNqd7Kng8UoRAqnYAKDWL9XQcMVkiUpLJheJQbx5nHDT/ACgzCM9
BCo4TWvJOFuyj9r815nIv50=
=x9hf
-----END PGP SIGNATURE-----
Marcus Meissner <meissner(a)suse.de> writes:
>> But why is there no warning when optimization is turned on? (When the
>> warning is actually needed :-) This is my main point.
>
> It is there with -Wall on SuSE Linux 9.0:
>
> $ cat xx.c
> void f(char *s) {
> while (*s) {
> *s++ = *s | 0x20;
> }
> }
> $ gcc -O2 -Wall -c xx.c
> xx.c: In function `f':
> xx.c:3: Warnung: operation on `s' may be undefined
It is the toupper that turns it off then:
markgray@soyo:/usr/src/packages/BUILD/bug> cat xx.c
#include <ctype.h>
void strupr_OLD (char *s)
{
while (*s) {
*s++ = toupper(*s);
}
}
markgray@soyo:/usr/src/packages/BUILD/bug> gcc -O2 -Wall -c xx.c
markgray@soyo:/usr/src/packages/BUILD/bug>
(This is also 9.0 btw)
Marcus Meissner <meissner(a)suse.de> writes:
>> while (*s) {
>> *s++ = toupper(*s);
>> }
>
>> loop. What exactly makes the old heretic code so wrong in the eyes of
>> ISO C? A list of example problematic code would be most welcome. (A
>> proper warning from gcc when using optimization would be nice as
>> well.)
>
> The problem here are so called 'sequence points'. ';' is such a sequence point.
>
> Using s and s++ within the same sequence will result in undefined behaviour like
> you noticed.
>
> while (*s) {
> ... do stuff ...
> s++;
> }
>
> is fine.
Ahah -- that I can see now when spelled out (the programmer only
mentioned a change, without any "legaleeze.")
But why is there no warning when optimization is turned on? (When the
warning is actually needed :-) This is my main point.
(I am an old 60's era FORTRAN and assembly language programmer myself,
and would use array notation in my own programs by the way :-)
This code is based on a recent patch to glheretic needed to make
heretic work correctly when compiled using gcc-3.3.*:
#include <ctype.h>
#include <stdio.h>
void strupr_OLD (char *s)
{
while (*s) {
*s++ = toupper(*s);
}
}
void strupr_NEW (char *s)
{
while (*s) {
*s = toupper(*s);
s++;
}
}
int main(void)
{
char test_old[] = "this is using strupr_OLD";
char test_new[] = "this is using strupr_NEW";
strupr_OLD(test_old);
printf("%s\n", test_old);
strupr_NEW(test_new);
printf("%s\n", test_new);
return 0;
}
When compiled WITH optimization:
markgray@soyo:/usr/src/packages/BUILD/bug> gcc -O2 -Wall -W bug.c
markgray@soyo:/usr/src/packages/BUILD/bug> ./a.out
HIS IS USING STRUPR_OLD
THIS IS USING STRUPR_NEW
markgray@soyo:/usr/src/packages/BUILD/bug>
Notice that there is NO warning given and that the old code has an
off-by-one error in it.
When compiled WITHOUT optimization:
markgray@soyo:/usr/src/packages/BUILD/bug> gcc -Wall -W bug.c
bug.c: In function `strupr_OLD':
bug.c:7: warning: operation on `s' may be undefined
markgray@soyo:/usr/src/packages/BUILD/bug> ./a.out
THIS IS USING STRUPR_OLD
THIS IS USING STRUPR_NEW
markgray@soyo:/usr/src/packages/BUILD/bug>
It does give a nice warning message -- but the code it produces works
as the original programmer intended. Why is there no warning given
when optimization is used -- and the warning is needed?
The programmer who posted the patch said that the change is due to an
ISO C change made to allow more aggressive optimization. Does anyone
have a list of what kinds of problematic code one should watch out for
in old C code?
I would argue that the old code has long been considered to be a
perfectly well defined C idiom (unlike the newby mistake i=i++), and
that code very much like it is very common in older C programs --
glheretic, for one, is still very buggy even after this one fix, so I
suspect that there are more "ISO C gotchas" lurking in it.
Looking at the kernel source code:
markgray@soyo:/usr/src/linux> find -name '*.[ch]' -print0|xargs --null \
grep -P '\*\w+\+\+\s*='|wc -l
3137
markgray@soyo:/usr/src/linux>
That's 3137 occurrences of '*symbol++ =' -- and looking at them in
context shows that a lot of them are part of a 'while(*something)'
loop. What exactly makes the old heretic code so wrong in the eyes of
ISO C? A list of example problematic code would be most welcome. (A
proper warning from gcc when using optimization would be nice as
well.)
alan(a)ibgames.com writes:
> Hi,
>
> I need to turn off the echo on a socket while I get a password.
>
> I tried:
>
> struct termios termios_p;
> tcgetattr(sd,&termios_p);
> termios_p.c_lflag &= ~ECHO;
> tcsetattr(sd,TCSANOW,&termios_p);
>
> where sd is the socket descriptor.
>
> It didn't seem to make any difference. Am I doing something wrong, or
> is this not the way it is done these days?
>
> Can any one assist, please?
Your socket is not necessarily a terminal (that is what pseudo
terminals are for) what exactly is on both sides of this socket?
Also you should check the error returns like so:
#include <termios.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
struct termios termios_p;
int sd = 0;
if(isatty(sd)) {
fprintf(stderr, "sd is a terminal\n");
} else {
fprintf(stderr, "sd is NOT a terminal\n");
}
if(tcgetattr(sd,&termios_p)) {
perror("tcgetattr failed");
exit(EXIT_FAILURE);
}
termios_p.c_lflag &= ~ECHO;
if(tcsetattr(sd,TCSANOW,&termios_p)) {
perror("tcsetattr failed");
exit(EXIT_FAILURE);
}
return 0;
}
Hi,
I need to turn off the echo on a socket while I get a password.
I tried:
struct termios termios_p;
tcgetattr(sd,&termios_p);
termios_p.c_lflag &= ~ECHO;
tcsetattr(sd,TCSANOW,&termios_p);
where sd is the socket descriptor.
It didn't seem to make any difference. Am I doing something wrong, or
is this not the way it is done these days?
Can any one assist, please?
Thanks
alan
--
http://www.ibgames.net/alan
Registered Linux user #6822 http://counter.li.org
Winding Down - Weekly Tech Newsletter - subscribe at
http://www.ibgames.net/alan/winding/mailing.html
I'm currently trying to improve my knowledge of C++ and writing as many programs as I can. My latest program has given me a problem and I can't seem to overcome it.
My initial program has come from a book I was reading and I am building on it to add more features.
It consists of a an ordering system using structures for stock.
At present everytime I start the program I have to populate the stock from scratch. Idealy I want to save the stock onto disk and load it everytime the program starts.
I am starting by populating by hand and then saving this to disk as I assumed this would be the easier bit, however I am having a little troube with this function.
After this, I am proposing to load the file back into the program within the structures and need help with this too although I have not yet made a start on this function.
I have search all my books and the net, but am strugling to find information to help me with this. Perhaps it is there but I am not sure of what I am looking for. Hopefully someone here can help.
For interest, here is my program at present:
#include <iostream>
#include <fstream>
using namespace std;
struct StockItem
{
int code;
char desc[20];
float price;
};
/*struct bill_line
{
StockItem product;
float weight;
float cost;
};
struct bill
{
bill_line items[20];
int num_lines;
};*/
void disp_menu(void);
struct StockItem enter_data();
void see_stock(StockItem stock[125], int num_items);
void save_data(StockItem save);
main()
{
StockItem stock[125];
int ans;
int num_items = 0;
do
{
do
{
disp_menu();
cin >> ans;
} while ((ans<1) || (ans>5));
switch (ans)
{
case 1:
stock[num_items] = enter_data();
num_items++;
break;
case 2:
see_stock(stock, num_items);
break;
case 3:
save_data(*stock);
break;
default:
break;
}
}while (ans!=6);
return 0;
system("PAUSE");
return 0;
}
void disp_menu()
{
cout << "\n*** The Corner Shop ***\n\n";
cout << "Select an option: \n\n";
cout << "\t1. Enter new stock " << endl;
cout << "\t2. See current stock " << endl;
cout << "\t3. Exit \n" << endl;
cout << "option> ";
}
StockItem enter_data()
{
StockItem stock_item;
cout << "\n\nWhat is the product code: ";
cin >> stock_item.code;
cout << "What is the product description: ";
fflush(stdin);
cin.getline(stock_item.desc, 20);
cout << "What is the product price: ";
cin >> stock_item.price;
return (stock_item);
}
void see_stock(StockItem stock[125], int num_items)
{
int ctr;
char ret;
cout << "\n\nHere is the stock listing:\n\n";
for (ctr = 0; ctr < num_items; ++ctr)
{
cout << "Item " << ctr+1 << endl;
cout << "Product Code: " << stock[ctr].code << endl;
cout << "Product Description: " << stock[ctr].desc << endl;
cout << "Price: " << stock[ctr].price << endl;
cout << "------------------------------------------------\n";
}
cout << "Press any key to return to the menu";
if (cin >> ret) //how do you make this work on a keystroke, and not requiring input then enter??
return;
}
//Problem section
void save_data(StockItem save)
{
fstream fp;
fp.open("items.txt", ios::in | ios::out);
if (!fp)
{
cout << "\n*** Error opening file ***\n";
exit(0);
}
fp << save;
fp.close();
}
-----------------------------------------
Email provided by http://www.ntlhome.com/
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tue, 16 Dec 2003 15:32:10 EST
KPP52(a)aol.com wrote:
> I have Personal 9.0
> I wrote the basic C program first.c
> then I did: gcc -o first first.c
> then I tried to run it by typing: first
> and it gives me a message: bash first no such command.
> so I tried: gcc first.c
> there was an a.out file in the directory
> then I typed: a.out
> and it gives me the same error message.
> Is there something I'm missing with the C compiler here?
> I'm new to SuSE and new to linux in general. I have done some C
> programming in Unix and this is confusing me tremendously. Any help
> would be greatly appreciated.
>
Let me add some clarifications to some of the postings on this. I think
that Keo gave the correct answer (This is what I posted to the SuSE
English list):
gcc -o first first.c
This creates the file, first, with the correct executable permissions.
gcc first.c
This creates a.out with the correct executable permissions.
As Gary mentioned, by default SuSE (and nearly every other Linux and
Unix system) does not include the current directory in your PATH
environment variable for security reasons. For this reason, you must use
either absolute or relative path to execute files that are not in your
PATH. For this reason, to execute anything in your current directory,
you must use the relative path (eg. ./<name of file> ) or the full path
(eg. /home/yourusername/<path to current directory>/<filename>).
So to execute first:
./first
or to execute a.out:
./a,out
- - --
Jerry Feldman <gaf(a)blu.org>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
iD8DBQE/37jz+wA+1cUGHqkRAjzSAJ0bYcV09uCoGQSsKiivq4X7q8BSXACcCaEi
KvO3Gwa4YJ9wVwfZNtpmroc=
=EyXP
- -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
iD8DBQE/37n9+wA+1cUGHqkRAj7FAJ9UNMv+zwLCPXisahxm3v6UJyTiYgCeKAOu
/eJ+vCk+vHY8zCBnW1LDzgc=
=d8HV
-----END PGP SIGNATURE-----