Skip to content

C++ keywords should not be in source #3823

@ctrlcctrlv

Description

@ctrlcctrlv
In file included from geom.cpp:18:0:
splinefont.h:660:18: error: expected identifier before ‘;’ token
struct fpc class;
           ^
splinefont.h:660:18: error: multiple types in one declaration
splinefont.h:1829:18: error: expected unqualified-id before ‘new’
unsigned int new: 1; /* A new and unsaved font */
             ^
splinefont.h:1855:20: error: expected unqualified-id before ‘private’
struct psdict private; / read in from type1 file or provided by user */
              ^
splinefont.h:1855:19: error: expected ‘;’ at end of member declaration
struct psdict private; / read in from type1 file or provided by user */
              ^
splinefont.h:1855:27: error: expected ‘:’ before ‘;’ token
struct psdict private; / read in from type1 file or provided by user */
^
splinefont.h:2352:68: error: expected ‘,’ or ‘...’ before ‘private’
extern int SFPrivateGuess(SplineFont *sf,int layer, struct psdict *private,
                                                                   ^

@repu1sion, who is helping me integrate Lib2Geom into FontForge, discovered this.

Sane C compilers, like GCC, will not allow you to link C++ code with C code that contains C++ keywords. Even if it might be technically possible, if you need to use the variables named after keywords in C++ code, you won't be able to.

There are many reasons you'd want to link C++ code with FontForge's code beyond my Lib2Geom integration. Therefore, I instructed @repu1sion to make a commit which will change all instances of C++ keywords to underscored versions. So private will become private_.

I know this might be contentious, so am making this issue so we can discuss it; perhaps someone knows a better way to use FontForge types from C++.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions