Const on a data declaration 
Author Message
 Const on a data declaration

When I create the following method:

HRESULT Test([in] const float *value);

everything compiles OK. But when I replace float with a user defined type I
get compile errors. The generated header file has lost the const keyword.
Does anybody know a solution?
And isn't it so that in theory all [in] parameters (pointers) can be const?

Thanks in advance,
Kurzweil



Fri, 20 Feb 2004 21:00:48 GMT  
 Const on a data declaration
Unfortunately, MIDL doesn't preserve const. This is unavoidable.
Try this idea (though I don't guarantee it will work):

#define CONST const
cpp_quote("#define CONST const")
// needed because MIDL removes #define-s
// now use CONST instead of const in your methods

The rationale behind is MIDL is case-sensitive.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> When I create the following method:

> HRESULT Test([in] const float *value);

> everything compiles OK. But when I replace float with a user defined type
I
> get compile errors. The generated header file has lost the const keyword.
> Does anybody know a solution?
> And isn't it so that in theory all [in] parameters (pointers) can be
const?

> Thanks in advance,
> Kurzweil



Sun, 22 Feb 2004 02:22:03 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. problem with array of const pointers to const data

2. const pointer to const data problem

3. How tightly does const bind within declaration?

4. const declarations in ANSI C

5. const convention in func prototypes/declarations

6. CONST after a function declaration

7. question on const declaration

8. extern const declaration

9. const declarations and arrays

10. const declarations and arrays

11. const declaration

12. Declaration of static const types

 

 
Powered by phpBB® Forum Software