Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot initialise structures with Pascal string constants #251

Open
mcayland opened this issue Jun 7, 2024 · 0 comments
Open

Cannot initialise structures with Pascal string constants #251

mcayland opened this issue Jun 7, 2024 · 0 comments

Comments

@mcayland
Copy link
Contributor

mcayland commented Jun 7, 2024

Whilst trying to compile the QEMU VGA driver I came across an error when trying to initialise a structure with a Pascal string constant which can be demonstrated as below:

#include <VideoServices.h>
#include <DriverServices.h>

DriverDescription TheDriverDescription = {
        /*
         * Signature info
         */
        kTheDescriptionSignature,               /* OSType driverDescSignature */
        kInitialDriverDescriptor,               /* DriverDescVersion driverDescVersion */
        "\p.Display_Video_QemuVGA",
        0x01, 0x01,
        0, 0,
        /*
         * DriverOSRuntime driverOSRuntimeInfo
         */
        0                                       /* RuntimeOptions driverRuntime */
        | (0 * kDriverIsLoadedUponDiscovery)    /* Loader runtime options */
        | (1 * kDriverIsOpenedUponLoad)         /* Opened when loaded */
        | (1 * kDriverIsUnderExpertControl)     /* I/O expert handles loads/opens */
        | (0 * kDriverIsConcurrent)             /* concurrent */
        | (0 * kDriverQueuesIOPB),              /* Internally queued */
        "\p.Display_Video_QemuVGA",             /* Str31 driverName (OpenDriver param) */
        0, 0, 0, 0, 0, 0, 0, 0,                 /* UInt32 driverDescReserved[8] */
        /*
         * DriverOSService Information. This section contains a vector count followed by
         * a vector of structures, each defining a driver service.
         */
        1,                                      /* ServiceCount nServices */
        /*
         * DriverServiceInfo service[0]
         */
        kServiceCategoryNdrvDriver,             /* OSType serviceCategory */
        kNdrvTypeIsVideo,                               /* OSType serviceType */
        1, 0, 0, 0
};

When compiled with powerpc-apple-macos-gcc test.c the following error is emitted:

test.c:10:9: error: cannot initialize array of 'unsigned char' from a string literal with type array of 'unsigned char'
   10 |         "\p.Display_Video_QemuVGA",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
test.c:10:9: note: (near initialization for 'TheDriverDescription.driverType.nameInfoStr')
test.c:22:9: error: cannot initialize array of 'unsigned char' from a string literal with type array of 'unsigned char'
   22 |         "\p.Display_Video_QemuVGA",             /* Str31 driverName (OpenDriver param) */
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
test.c:22:9: note: (near initialization for 'TheDriverDescription.driverOSRuntimeInfo.driverName')

If I change the constants from e.g. "\p.Display_Video_QemuVGA" to "\n.Display_Video_QemuVGA" then compilation succeeds so it seems to be related to the implementation of Pascal string constants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant