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 1946
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: 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: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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...
| |