36

I have searched this up rather a lot, but come up with no helpful results.

I am currently trying to program simple DirextX game for Windows 8 Metro, and have come across _In_ rather a lot. I'm just wondering what it is.

Also, I have seen a lot of the use of ^ as the pointer * which I found odd. On top of this, some classes have an interface of ref class MyClass, which I believe is for C# legibility.

Anyway, any help would be brilliant.

Roland
  • 7,525
  • 13
  • 61
  • 124
Infinity James
  • 4,667
  • 5
  • 23
  • 36
  • 4
    `SomeType^` is a C++/CLI managed pointer. That isn't C++. – chris Jul 12 '12 at 17:33
  • 8
    Neither of these is really C++ at all. They're C++/CLI or perhaps C++/CX (or possibly the older "Managed C++"). Every few years, Microsoft invents a new language based on C++, but with extensions for their "managed" environment (.NET). So far, none of these has gained much popularity (to put it mildly). – Jerry Coffin Jul 12 '12 at 17:34
  • 1
    This might be related: [Should we use _In_ instead of __in?](http://stackoverflow.com/questions/4093053/should-we-use-in-instead-of-in) – Desmond Hume Jul 12 '12 at 17:34
  • 2
    as he mentions Metro, I'd say that that's part of C++/CX for WinRT... – MFH Jul 12 '12 at 18:49
  • `^` is _not_ a pointer. – IS4 Mar 21 '17 at 21:42

4 Answers4

38

It is a SAL annotation, used for code analysis. The annotations themselves are defined as macros that, in normal builds, expand to nothing.

The ^ and ref class are features of C++/CX, a set of language extensions developed to make it easier to build Metro style apps for Windows 8 in C++. Neither is a part of standard C++. The documentation (linked previously) has links to tutorials and references describing the language extensions.

James McNellis
  • 348,265
  • 75
  • 913
  • 977
0

I think (from a quick google) that the _in_ is there to indicate if a parameter is an input or output (_out_) to a function/method.

The ^ is a managed pointer (garbage collected pointer, related to C++/CLI).

adam_0
  • 6,920
  • 6
  • 40
  • 52
Max
  • 3,128
  • 1
  • 24
  • 24
  • 1
    Ha, I thought that said `ln`, not `in`. That's indeed the purpose with Microsoft. – chris Jul 12 '12 at 17:35
  • 1
    @DeadMG Actually, [it is a reference _handle_](http://msdn.microsoft.com/en-us/library/windows/apps/hh699870.aspx), **not** a pointer. – Cole Tobin Feb 18 '13 at 02:07
0

In sal.h file o found this definition

// Input parameters --------------------------

//   _In_ - Annotations for parameters where data is passed into the function, but not modified.
//          _In_ by itself can be used with non-pointer types (although it is redundant).

// e.g. void SetPoint( _In_ const POINT* pPT );
#define _In_                            _SAL2_Source_(_In_, (), _Pre1_impl_(__notnull_impl_notref) _Pre_valid_impl_ _Deref_pre1_impl_(__readaccess_impl_notref))
#define _In_opt_                        _SAL2_Source_(_In_opt_, (), _Pre1_impl_(__maybenull_impl_notref) _Pre_valid_impl_ _Deref_pre_readonly_)
Cengizz
  • 25
  • 2
  • 8
-1

_Out_ means argument passed as reference. _In_ means the opposite. (_Out_ x) and (&x) are similar.

adam_0
  • 6,920
  • 6
  • 40
  • 52
Diptendu
  • 23
  • 1