const_at_typedefed_type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux