I have 2 libs that have different case on different platforms :(. It seems like everything else is the same (method names, param order, etc). How can i create an alias so my current spelling for platform a will work when i compile for platform b (I would really hate to make a wrapper for case difference)
- Can you give (simplified) code for what you mean? Most likely there is a better way to do this.Matthew Flaschen– Matthew Flaschen2009-05-10 03:53:58 +00:00Commented May 10, 2009 at 3:53
- possible duplicate of How do I alias a class name in C#?nawfal– nawfal2014-07-16 11:52:59 +00:00Commented Jul 16, 2014 at 11:52
2 Answers
You can use the using keyword to create an alias:
using MyName = YourNamespace.YourSubNamespace.YourType; You could then conditionally include the aliases using a #if directive. However you would need to do this at the top of every source file: there's no #include-like directive to allow you to create a file of aliases and import them into each source file. So if you are planning on doing this in for a large codebase then it may be worth considering another approach such as the wrapper approach.
Comments
In C#, you can create an alias for a namespace or a type. It's not quite as flexible as typedef, but it might make it possible for you to alias the type in your lib a to have the lowercase (or uppercase or whatever) like you want to do.