llabs not working
Building code with using llabs, I get the error
"utioHeader.cc", line 4224: Error: The function "llabs" must have a prototype.
I am working in Linux rf4 with SunStudio 12.
This is defined in stdlib.h, but is defined as
#ifdef __USE_ISOC99
__extension__ extern long long int llabs (long long int __x)
__THROW __attribute__ ((__const__));
#endif
So I presume I am having an issue with the standards and what should be defined.
Suggestions?
Message was edited by:
Brett_Tiplitz
# 1
I assume you are using C++, as with C compiler it should just work.
Our C++ compiler does not yet fully support C99, so we do not assert USE_ISOC99.
You can cross your fingers and enable it by yourself by using -D_ISOC99_SOURCE.
It can fail miserably though :)
regards,
__Fedor.
SFVa at 2007-7-11 22:43:45 >

# 3
We are still resolve issues with the Linux headers for C++. The headers don't work right unless the compiler asserts that it is g++. But asserting g++ also requires handling g++ extensions and implementation details that we do not yet support.
We have resolved quite a number of header issues in the release version. We will have more issues resolved in the first patch for C++ 5.9 on Linux.
# 4
I looked a the llabs further. I am confused about this one. I can see in both Linux and Solaris that llabs is not in the std namespace. There was a reference to llabs being in the std namespace in the draft spec I found but there was clearly a bug in the standard as it says it should be there, and then later on in the list, the call is missing.
So what is right. It seems to work on Linux, but it seems that it should not work.
Thanks
# 6
The issue about names from the C standard and the C++ std namespace is complicated. The short version is that Solaris conforms to the requirements of the C++ standard, but Linux and g++ do not. Examples:
This program is valid C++, compiles with Sun C++ on Solaris, but not with g++ on Linux:
#include <stdio.h>
int main()
{
std::printf("Hello\n");
}
This program is not valid C++ (printf should not be visible). Sun C++ on Solaris emits an error message. G++ on Linux compiles the code.
#include <cstdio>
int main()
{
printf("Hello\n");
}
For Sun C++ to conform to the standard on Linux, we could not use the Linux or g++ headers, but would have to write our own. Since details of the headers vary with different Linux distributions and different g++ versions. the task is impossible. In addition, our eventual aim is to compile programs on Linux that compile with g++, apart from simple compiler bugs.
Consequently, our approach on Linux is to use the Linux/g++ headers on the system, and not try to do a better job than g++ of conforming to the standard regarding names in headers.
I already addressed your comment about asserting that the compiler is g++. We are not yet close enough to g++ to handle all the consequences of such an assertion. We expect to get there later.
# 7
No try using llabs instead of printf. The result will change. I can not have the std on Solaris or linux/gcc, which I uncertain if this allowed on the standard.Further, the studio/Linux build will not compile code no matter how it's specified.
# 10
llabs is a C99 function, but as all the long long functions it was not part of C89 and thus not part of C++03. Therefore, it should not get defined when you #include <cstdlib>, and under no circumstances can it be accessed as std::llabs. This will change with the next C++ standard.