Richard Thrippleton schrieb: > Gary R. Van Sickle wrote: >>> From: Richard Thrippleton >>> the generated code for that rule will start with >>> >>> "std::vector<int> foo = NULL;" >>> >> Really, it adds that "= NULL" of its own volition? That sounds like >> a bug. All kinds of C PODs (structs for instance) could be in there, >> none of which could be pointers, and that should then fail on C as >> well as C++. What version is this? > Yeah, I'm pretty mystified by this. I'm definitely not trying to NULL > anything myself. By experimentation, it looks like it _tries_ to do the > right thing for different datatypes e.g. it will 0 an int.
The templates contain a map structure which allows to set the default values for a certain number of predefined types. The problem with this approach is that it requires a language with only a limited number of value types. Otherwise it uses the default initialization which assumes pointers. C# has solved the problem with using the default keyword (which initializes structs with the default constructor, which is the 0-bit pattern, and for references simply null) but I don't think that C(++) has an equivalent. Johannes >> Like I noted above, you will run into problems due to the malloc() >> vs. new thing. At least I did the last time I tried it. > Well, I guess this is good news for you then ... should Just Work on > 3.1.1 and higher :-) > > Richard > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
