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)

2
  • Can you give (simplified) code for what you mean? Most likely there is a better way to do this. Commented May 10, 2009 at 3:53
  • possible duplicate of How do I alias a class name in C#? Commented Jul 16, 2014 at 11:52

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments