This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
const_at_typedefed_type
- From: Kalugsky Uriy <urik at kiam1 dot rssi dot ru>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 19 Oct 2007 17:22:31 +0400 (MSD)
- Subject: const_at_typedefed_type
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*)'