* RFC: g++ compiler flag usage
@ 2005-06-06 11:41 Mws
2005-06-06 12:04 ` Eljay Love-Jensen
0 siblings, 1 reply; 4+ messages in thread
From: Mws @ 2005-06-06 11:41 UTC (permalink / raw)
To: gcc-help
[-- Attachment #1: Type: text/plain, Size: 696 bytes --]
hi,
as i am using -Werror and also -Wold-style-cast and many more flags,
i do run into some problems when compiling code,
that uses e.g. the FD_SET(int, fd_set*) makro.
of course, i can ommit the -Wold-style-cast or the -Werror flag, and everything will compile fine,
just showing up some warnings. but, i feel very uncomfortable with that situation.
isn't there a possibility e.g to have a
#ignore Wflags
FD_SET(...,...);
#endignore
that would be helpfull for more people than only me, i think.
having different compiler flags depending on what _can_ be checked within a project is much more
confusing imho.
any opinions? or did i miss something?
regards
marcel
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFC: g++ compiler flag usage
2005-06-06 11:41 RFC: g++ compiler flag usage Mws
@ 2005-06-06 12:04 ` Eljay Love-Jensen
2005-06-06 12:28 ` Mws
0 siblings, 1 reply; 4+ messages in thread
From: Eljay Love-Jensen @ 2005-06-06 12:04 UTC (permalink / raw)
To: Mws, gcc-help
Hi Marcel,
FD_SET is a C macro function that happens to work in C++.
>any opinions? or did i miss something?
Yes: #undef the FD_SET macro function, and create the C++ equivalent that complies to the rigorous settings you are using.
Alternatively, use FD_SET in C code, and think compile your C++ code against your C code thunk layer.
HTH,
--Eljay
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFC: g++ compiler flag usage
2005-06-06 12:04 ` Eljay Love-Jensen
@ 2005-06-06 12:28 ` Mws
2005-06-06 14:46 ` Eljay Love-Jensen
0 siblings, 1 reply; 4+ messages in thread
From: Mws @ 2005-06-06 12:28 UTC (permalink / raw)
To: gcc-help
[-- Attachment #1: Type: text/plain, Size: 2011 bytes --]
On Monday 06 June 2005 13:56, Eljay Love-Jensen wrote:
> Hi Marcel,
>
> FD_SET is a C macro function that happens to work in C++.
>
> >any opinions? or did i miss something?
>
> Yes: #undef the FD_SET macro function, and create the C++ equivalent that complies to the rigorous settings you are using.
>
> Alternatively, use FD_SET in C code, and think compile your C++ code against your C code thunk layer.
yes it works, but not with the -W flags i mentioned.
e.g. compilation will fail on x86 but not on ppc
(given i as fd and rfds as fd_set)
FD_SET(i, &rfds);
is expanded on x86 architecture to
__asm__ __volatile__ ("btsl %1,%0" : "=m" ((&rfds)->fds_bits)[((i) / (8 * sizeof (__fd_mask)))]) : "r" (((int) (i)) % (8 * sizeof (__fd_mask))) : "cc","memory");
and on mpc/ppc architecture to
(((&rfds)->fds_bits)[((i->first) / (8 * sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((i->first) % (8 * sizeof (__fd_mask)))));
as i want to have ( as that seems to be possible without using supporting warning flags ) platform independ code,
i do not like the alternative you offered me, cause i would have to redesign a given wheel :)
would you like to read a
#ifdef X86VERSION
__asm__ __volatile__ ("btsl %1,%0" : "=m" ((&rfds)->fds_bits)[((i) / (8 * sizeof (__fd_mask)))]) : "r" ((static_cast<int>(i)) % (8 * sizeof (__fd_mask))) : "cc","memory");
#endif
#ifdef PPCVERSION
(((&rfds)->fds_bits)[((i->first) / (8 * sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((i->first) % (8 * sizeof (__fd_mask)))));
#endif
#ifdef MIPSVERSION
......
#endif
i think the advantages is that you just can just write
FD_SET(i, &rfds);
instead having those constructs mentioned above.
i do not want to do a compilers work, so i think if there isn't a applicable of FD_SET(...,...) in c++ and you
are forced to use c functions - the compiler should be
a) able to detect it on his own, or
b) let the coder declare critic sections
regards
marcel
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFC: g++ compiler flag usage
2005-06-06 12:28 ` Mws
@ 2005-06-06 14:46 ` Eljay Love-Jensen
0 siblings, 0 replies; 4+ messages in thread
From: Eljay Love-Jensen @ 2005-06-06 14:46 UTC (permalink / raw)
To: Mws, gcc-help
Hi Marcel,
>i do not want to do a compilers work...
C++ in general (or GCC's g++ in particular) do not provide FD_SET.
FD_SET is provided by the system.
>...so i think if there isn't a applicable of FD_SET(...,...) in c++ and you are forced to use c functions - the compiler should be
a) able to detect it on his own, or
b) let the coder declare critic sections
Since the compiler does not provide FD_SET, I do not think (a) is a reasonable expectation.
I've already provided you with a suggestion for how to utilize FD_SET in a C file, and then call that extern "C" routine in your C++ program. That C thunk layers acts as a critical section, for your (b) expectation.
If you really want to use C++, then you could put the FD_SET in a C++ source file that is compiled with different flags from the rest of your source code. That separate source file on its own acts as a critical section.
Sincerely,
--Eljay
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-06-06 14:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-06 11:41 RFC: g++ compiler flag usage Mws
2005-06-06 12:04 ` Eljay Love-Jensen
2005-06-06 12:28 ` Mws
2005-06-06 14:46 ` Eljay Love-Jensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).