const_at_typedefed_type
Kalugsky Uriy
urik@kiam1.rssi.ru
Fri Oct 19 13:27:00 GMT 2007
Hello,
Could you explain, please, why the compiler ignores the 'const'
in the functiion 'char_const_param(const TStr name)'.
Best regards,
Yury
==================================
The operating system - FreeBSD 6.2
==================================
GCC Version
===========
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.6 [FreeBSD] 20060305
The code to compile
===================
#include <iostream>
#include <iomanip>
typedef char* TStr ;
void char_const_param(const TStr name)
{
std::cout << name << std::endl ;
}
int main (void)
{
const char * const_buf= "CONST ---> TYYYYYYYYYYYYY TYYYYYYYY" ;
char_const_param(const_buf) ;
std::cout <<"\nSIZEOF(double) " << sizeof(double) << std::endl ;
return 0 ;
}
The compiler messages
========================
./typedef_feature.cpp: In function `int main()':
./typedef_feature.cpp:18: error: invalid conversion from `const char*' to `char*'
./typedef_feature.cpp:18: error: initializing argument 1 of `void char_const_param(char*)'
More information about the Gcc-help
mailing list