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

[Auto-Sync] Translate templates to functions and not macros #2135

Open
Rot127 opened this issue Aug 5, 2023 · 0 comments
Open

[Auto-Sync] Translate templates to functions and not macros #2135

Rot127 opened this issue Aug 5, 2023 · 0 comments

Comments

@Rot127
Copy link
Collaborator

Rot127 commented Aug 5, 2023

Currently C++ template functions are translated to macros:

template<int targ>
void func() {
   return targ;
}

becomes

#define DEFINE_func(targ) \
   void func_##targ() { \
   return targ; \
}

This is helpful, because targ can also be a type. Also it mimics the sematic closer.

On the other hand it leads to many many duplicated functions and is bad for general obj file size.
Also it is annoying to debug (you cannot set breakpoints in macros).

The CppTranslator should instead generate the templates as functions and pass the template arguments via additional parameter.

The edge case of template<typename T> must be handled somehow.

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

No branches or pull requests

1 participant