Skip to content

[cxx-interop] Fix typo in getting started, and update example for creating the cxx module #41712

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

Conversation

cabmeurer
Copy link
Contributor

@cabmeurer cabmeurer commented Mar 7, 2022

Fixed the typo in the cmake section and updated the creating module section with a more accurate example.

I found that when you create a C++ module, and defined file for header in the module doesnt contain the implimentation for the methods, an error is produced stating Undefined symbol: _cxxFunction, clang: error: linker command failed with exit code 1 (use -v to see invocation)

I updated the docs to have the implementation of methods in the header file, however we could change the example as seen below:

//In module.modulemap
module Cxx {
    header "Cxx.cpp"
}

// in Cxx.hpp
#ifndef Cxx_hpp
#define Cxx_hpp
int cxxFunction(int n);

#endif

//in Cxx.cpp
#include "Cxx.hpp"

int cxxFunction(int n) {
    return n;
}

@cabmeurer cabmeurer changed the title Fix typo in getting started, and update example for creating the cxx module [cxx-interop] Fix typo in getting started, and update example for creating the cxx module Mar 7, 2022
@cabmeurer
Copy link
Contributor Author

@hyp @zoecarver

@zoecarver zoecarver added the c++ interop Feature: Interoperability with C++ label Mar 8, 2022
@zoecarver
Copy link
Contributor

@swift-ci please smoke test.

@zoecarver zoecarver merged commit e6d8912 into swiftlang:main Mar 9, 2022
@cabmeurer cabmeurer deleted the cxx-interop/Fix-typo-update-example-cxx-module branch March 9, 2022 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants