ADC Home > Reference Library > Technical Q&As > QuickTime > QuickTime for Windows >
|
Q:
I'm porting some QuickTime code from Macintosh over to Windows
where I'm using Visual C++. I've run into some annoying issues
creating pascal strings. I keep getting access violations
calling A: The most likely reason for the access violations is that the string data is in read-only memory. C strings start with the first character of the string and are terminated with a null character (ASCII value zero). Pascal strings start with a length byte and have no termination character. On the Macintosh, they have different types: C strings are Pascal strings are When you call For example, You should never pass a literal C string to While C compilers on the Macintosh support the To help code portability, QTML (QuickTime Media Layer) frequently
examines Pascal strings which have their length byte set
to 112 ( Developers taking advantage of this QTML feature must take care to put such Pascal strings in writable memory. You may be able to configure your development system to do this. Alternatively, you can make the string the initializer for a non-constant
string buffer:
Developers should note, there are recommended functions available for
converting between C and Pascal Strings.
While these functions were written to allow in-place conversion, (i.e. The src and dst parameters can point to the same memory location) they do not suffer from the restriction of only doing in-place conversions which as mentioned, can cause you to incorrectly change the contents of a read-only buffer or easily cast away a const. [Jan 21 2002] |
|