This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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*)'


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]