Hi,
In some C code I see a PRIVATE macro corresponding to the static
keyword and a PUBLIC macro that has no correspondent. Why do people
prefer using such macros rather than using static? Better readability?
Thanks,
Bahadir 7 2693 Bi*************@gmail.com wrote: Hi,
In some C code I see a PRIVATE macro corresponding to the static keyword and a PUBLIC macro that has no correspondent. Why do people prefer using such macros rather than using static? Better readability?
No. They're C++/O-O programmers who *think* macros like this give better
readability. This is true only if you think C should be like C++, in which
case you shouldn't be using C and stick to C++.
Although macros are no substitute for knowing what you're doing and letting
others know as well, they're commonly used this way.
S.
Skarmander wrote: Bi*************@gmail.com wrote: Hi,
In some C code I see a PRIVATE macro corresponding to the static keyword and a PUBLIC macro that has no correspondent. Why do people prefer using such macros rather than using static? Better readability? No. They're C++/O-O programmers who *think* macros like this give better readability. This is true only if you think C should be like C++, in which case you shouldn't be using C and stick to C++.
Although macros are no substitute for knowing what you're doing and letting others know as well, they're commonly used this way.
<OT>
They are also used because sometimes for using non-standard things like
DLLs you have to use non-standard things like __declspec(dllexport)
where on other systems you don't.
</OT>
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Flash Gordon said: <OT> [Macros] are also used because sometimes for using non-standard things like DLLs you have to use non-standard things like __declspec(dllexport) where on other systems you don't. </OT>
I don't know of any system where _declspec(dllexport) *must* be used in DLL
code. It's certainly not the case in Windows. I've written loads of - well,
quite a few - Windows DLLs with nary a declwhatever in sight, and they
ported perfectly well to, say, Linux without changing a single line of
source. And no, I wasn't hiding everything behind macros either. You *do
not need* to write convoluted junk in a Windows DLL. (That doesn't mean you
can't, obviously.)
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Richard Heathfield a écrit : Flash Gordon said:
<OT> [Macros] are also used because sometimes for using non-standard things like DLLs you have to use non-standard things like __declspec(dllexport) where on other systems you don't. </OT>
I don't know of any system where _declspec(dllexport) *must* be used in DLL code. It's certainly not the case in Windows. I've written loads of - well, quite a few - Windows DLLs with nary a declwhatever in sight, and they ported perfectly well to, say, Linux without changing a single line of source. And no, I wasn't hiding everything behind macros either. You *do not need* to write convoluted junk in a Windows DLL. (That doesn't mean you can't, obviously.)
If you do not use __declspec(dllexport) how does the linker know
which symbols to export?
Obviously it soesn't, so that exports everything.
This works, but is inneficient, and can lead to name conflicts.
It is better to export only those names that you need to export
from a dll.
jacob navia said: If you do not use __declspec(dllexport) how does the linker know which symbols to export?
By the use of a definitions file. Obviously it soesn't, so that exports everything.
Wrong.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
jacob navia wrote: Richard Heathfield a écrit : Flash Gordon said:
<OT> [Macros] are also used because sometimes for using non-standard things like DLLs you have to use non-standard things like __declspec(dllexport) where on other systems you don't. </OT>
I don't know of any system where _declspec(dllexport) *must* be used in DLL code. It's certainly not the case in Windows. I've written loads of - well, quite a few - Windows DLLs with nary a declwhatever in sight, and they ported perfectly well to, say, Linux without changing a single line of source. And no, I wasn't hiding everything behind macros either. You *do not need* to write convoluted junk in a Windows DLL. (That doesn't mean you can't, obviously.) If you do not use __declspec(dllexport) how does the linker know which symbols to export?
<snip OT stuff I happen to agree with>
This is all rather off topic. I was just wanting to point out that there
are reasons (whether good or bad) people sometimes use macros rather
than using extern, I did not intend to start a debate about the correct
way to export symbols from a DLL.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
On Thu, 29 Dec 2005 14:39:01 +0100, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.fr> wrote: If you do not use __declspec(dllexport) how does the linker know which symbols to export?
*obviously* by some other means which is linker-dependent.
I'm actually surprised you don't know how to do this.
It is better to export only those names that you need to export from a dll.
Indeed. I suspect that "static" will be helpful here.
Mark McIntyre
--
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =---- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: IHateSuperman |
last post by:
public class StaticField2{
public static void main(String args){
private int x, y; // <<== error 1
for ( y = 0 ; y < 100 ; y++){
x = StaticMethod();
System.out.println(" x = "+x);
}
}
public...
|
by: Chris Reedy |
last post by:
For everyone -
Apologies for the length of this message. If you don't want to look
at the long example, you can skip to the end of the message.
And for the Python gurus among you, if you can...
|
by: z_learning_tester |
last post by:
Quick question-
What happens if you have a private class with a public static method?
Can you still say the following?
Lets say you are making this call from another class, say class2...
int...
|
by: Sahil Malik [MVP] |
last post by:
Public Private Key Pairs - How do they work?
-----------------------------------------------
I was looking at a presentation recently in which it was suggested that -
User 1 Encrypts a message...
|
by: Sky |
last post by:
Hello:
I'm trying to make sense of snk files, when to use, under what conditions to
regenerate new ones,...can someone take a look if these statemes make sense?
And then the final questions at the...
|
by: WXS |
last post by:
I know this sounds contrary to the idea of an interface, but read this and
see what you think.
-----------------------------------------------------------------------------------------
It would be...
|
by: t f |
last post by:
Hi
I have a class with a bunch of private variables in, is there an easy
way to make these have public properties without having to type it all in?
e.g.
public class Fu
{
private float...
|
by: PengYu.UT |
last post by:
Hi,
I want to write a test function to test a class. The class has a
private member function that need to be tested. Although I could
modify the member function as protected or public, I do not...
|
by: Peng Yu |
last post by:
Hi,
I'm wondering if there is something in namespace like the 'private'
keyword in class?
I want to define some class or function that can only be used within
that namespace.
Thanks,
Peng
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |