Hello,
I would like to have the preprocessor form a string containing the value
of INT_MAX from limits.h but I am fairly certain that this is impossible
using C alone... yes I could call sprintf, but I would have liked some
solution based on the preprocessor, so that I can have my string
literal ready at compile time instead of at run time. Oh well..
Thanks,
Neil 4 1954
Neil Zanella wrote: Hello,
I would like to have the preprocessor form a string containing the value of INT_MAX from limits.h but I am fairly certain that this is impossible using C alone... yes I could call sprintf, but I would have liked some solution based on the preprocessor, so that I can have my string literal ready at compile time instead of at run time. Oh well..
This is FAQ 11.17. See sig for URL.
(Haven't checked online FAQ. It's in the book copy, for sure.)
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
[Sorry if this is a duplicate. God bless KNode...grrr...]
Neil Zanella wrote: Hello,
I would like to have the preprocessor form a string containing the value of INT_MAX from limits.h but I am fairly certain that this is impossible using C alone... yes I could call sprintf, but I would have liked some solution based on the preprocessor, so that I can have my string literal ready at compile time instead of at run time. Oh well..
See FAQ 11.17, which describes precisely how to do this. See my sig for the
URL.
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Neil Zanella wrote: I would like to have the preprocessor form a string containing the value of INT_MAX from limits.h but I am fairly certain that this is impossible using C alone... yes I could call sprintf, but I would have liked some solution based on the preprocessor, so that I can have my string literal ready at compile time instead of at run time. Oh well..
This is Frequently Asked Question number 11.17 http://www.eskimo.com/~scs/C-faq/q11.17.html
(Strike two.)
Richard Heathfield wrote: Neil Zanella wrote:
Hello,
I would like to have the preprocessor form a string containing the value of INT_MAX from limits.h but I am fairly certain that this is impossible using C alone... yes I could call sprintf, but I would have liked some solution based on the preprocessor, so that I can have my string literal ready at compile time instead of at run time. Oh well..
This is FAQ 11.17. See sig for URL.
(Haven't checked online FAQ. It's in the book copy, for sure.)
Stringizing the macro's definition might not satisfy
the O.P.'s need. The result might be any of "32767",
"0x7fff", "077777", "__intmax", or even stranger strings.
-- Er*********@sun.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jeremy Siek |
last post by:
CALL FOR PAPERS/PARTICIPATION
C++, Boost, and the Future of C++ Libraries
Workshop at OOPSLA
October 24-28, 2004
Vancouver, British Columbia, Canada
http://tinyurl.com/4n5pf
Submissions
|
by: Nudge |
last post by:
I have an array, and an unrolled loop which looks like this:
do_something(A);
do_something(A);
....
do_something(A);
I thought: why should I type so much? I should write a macro.
So I was...
|
by: Jim Ford |
last post by:
I have a single C file with the following code:
int f2()
{
/* Blah-blah */
}
int f1()
{
/* Blah-blah */
|
by: Chris Croughton |
last post by:
Is the following code standard-compliant, and if so what should it do?
And where in the standard defines the behaviour?
#include <stdio.h>
#define DEF defined XXX
int main(void)
{
int...
|
by: Avin Patel |
last post by:
Hi,
I have written C# code. And I have used preprocessor / macro in it.
I want to get the C# code after processing preprocessor, I have defined
durcng compile time. How can I get this code?
...
| |
by: spibou |
last post by:
Is the output of the C preprocessor deterministic ? What I mean
by that is , given 2 compilers which conform to the same standard,
will their preprocessors produce identical output given as input...
|
by: ludovicd |
last post by:
Hi to all,
There is my question, Let's say I got a fonction which takes a numeric
argument long enough so that there has to be spaces in it to represent
it correctly. (Ex. 0xf63a002c5ff0338ec...
|
by: Sam of California |
last post by:
Is it accurate to say that "the preprocessor is just a pass in the parsing
of the source file"?
I responded to that comment by saying that the preprocessor is not just a
pass. It processes...
|
by: abir |
last post by:
Hi,
This is not strictly a C++ language question.
Is there any way to form a string from an identifier with the
preprocessor with some operations ?
i.e to say to make a string from an...
|
by: Bob |
last post by:
Hi,
Is it possible to change the references in a project by using
preprocessor directives?
Thanks,
Bob
|
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: 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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
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...
| |