Similar macros like "CONST_INT" in product code. Does it deserve this?
Thank you for your time.
/* a.h ************************************************** *********/
#ifndef CONST_INT
#define CONST_INT(name, value) extern const int name
#endif
#ifndef CONST_DBL
#define CONST_DBL(name, value) extern const double name
#endif
#ifndef CONST_STR
#define CONST_STR(name, value) extern const char *name
#endif
/*more defs...*/
CONST_INT(age, 18);
CONST_DBL(len, 19.9);
CONST_STR(usenet, "clc");
/*more consts...*/
/* a.c ************************************************** *********/
#include <stdio.h>
#include "a.h"
CONST_INT(age, 18) = 18;
CONST_DBL(len, 19.9) = 19.9;
CONST_STR(usenet, "clc") = "clc";
/*more consts...*/
int a(void){
printf("%d, %f, %s\n", age, len, usenet);
/*more stuff*/
return 0;
} 2 1449
lovecreatesbea...@gmail.com wrote:
Similar macros like "CONST_INT" in product code. Does it deserve this?
Thank you for your time.
/* a.h ************************************************** *********/
#ifndef CONST_INT
#define CONST_INT(name, value) extern const int name
#endif
#ifndef CONST_DBL
#define CONST_DBL(name, value) extern const double name
#endif
#ifndef CONST_STR
#define CONST_STR(name, value) extern const char *name
#endif
/*more defs...*/
CONST_INT(age, 18);
CONST_DBL(len, 19.9);
CONST_STR(usenet, "clc");
/*more consts...*/
/* a.c ************************************************** *********/
#include <stdio.h>
#include "a.h"
CONST_INT(age, 18) = 18;
CONST_DBL(len, 19.9) = 19.9;
CONST_STR(usenet, "clc") = "clc";
/*more consts...*/
int a(void){
printf("%d, %f, %s\n", age, len, usenet);
/*more stuff*/
return 0;
}
Looks silly: Why specify each value twice? I suspect
you've overlooked a set of alternative definitions of the
macros, that look something like
CONST_INT(name value) const int name = (value)
.... the idea being to put `CONST_INT(age, 18);' in a lot
of files (probably by way of #include), where most use
the first CONST_INT definition and exactly one uses the
second.
-- Er*********@sun.com
On Feb 28, 11:35 pm, Eric Sosman <Eric.Sos...@sun.comwrote:
lovecreatesbea...@gmail.com wrote:
Similar macros like "CONST_INT" in product code. Does it deserve this?
Thank you for your time.
/* a.h ************************************************** *********/
#ifndef CONST_INT
#define CONST_INT(name, value) extern const int name
#endif
#ifndef CONST_DBL
#define CONST_DBL(name, value) extern const double name
#endif
#ifndef CONST_STR
#define CONST_STR(name, value) extern const char *name
#endif
/*more defs...*/
CONST_INT(age, 18);
CONST_DBL(len, 19.9);
CONST_STR(usenet, "clc");
/*more consts...*/
/* a.c ************************************************** *********/
#include <stdio.h>
#include "a.h"
CONST_INT(age, 18) = 18;
CONST_DBL(len, 19.9) = 19.9;
CONST_STR(usenet, "clc") = "clc";
/*more consts...*/
int a(void){
printf("%d, %f, %s\n", age, len, usenet);
/*more stuff*/
return 0;
}
Looks silly: Why specify each value twice? I suspect
you've overlooked a set of alternative definitions of the
macros, that look something like
CONST_INT(name value) const int name = (value)
I've paied special attention on this. They just don't have the "value"
arg in the macro bodies. I guess the literal values in the
declarations in the header are just like comments. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: niyong |
last post by:
--
Hop@Ni
|
by: Bit byte |
last post by:
I have the following methods:
static void Foo::setBar(const Bar*) ; //store a copy of Bar
static const Bar* Foo::getBar(void) const ; //return an UNMODIFIABLE ptr
to our internal copy
In...
|
by: kestrel |
last post by:
i had it a while ago, but i forgot...
heres what i have.<input type="button" value="Submit" onclick="this.disabled=1; this.value=Sending;">
i can get the button to disable, but the value wont...
|
by: miaohua1982 |
last post by:
the code is as follows:
#include<stdio.h>
int arr={1,2,3,4,5,6,7};
#define size (sizeof(arr)/sizeof(arr))
int main()
{
int index = -1;
int x = 0;
int t;
|
by: gert |
last post by:
Can you replace this->value with *this.value in c ?
| |
by: priyanka1915 |
last post by:
Situation is : i got output like open=4324= volumn=435.456, change=56, etc... now i want to enter this value in table and this value updates after 3 sec and it should also update in dat table
|
by: AKS |
last post by:
Hi! Here's a small test case (for Firefox):
var o = {
p: {
func: function () {},
},
test: function () {
var msg = ;
var d = new Date;
|
by: parag_paul |
last post by:
I understand that a const qualifier after the function declaration
makes it a const function for the class.
Like
int func1 const ( double, long int );
Now what is the purpose of the...
|
by: sushilkaushik |
last post by:
In my VC++ project (using Visual Studio 2005) I have two DLLs : CommonClasses.dll and CheckIn.dll
I added both of them in exactly the same way. First, CommonClesses and then CheckIn, using...
|
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,...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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 ...
|
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...
| | |