3

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 May 10 '09 at 03:53
  • possible duplicate of [How do I alias a class name in C#?](http://stackoverflow.com/questions/244246/how-do-i-alias-a-class-name-in-c) – nawfal Jul 16 '14 at 11:52

2 Answers2

5

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.

itowlson
  • 73,686
  • 17
  • 161
  • 157
1

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.

JP Alioto
  • 44,864
  • 6
  • 88
  • 112