Страница 1 из 2

#using

Добавлено: 15 фев 2005, 13:41
Иван Михайлов
Подскажите пожалуйста, как настроить проект Visual C++ 7 .NET, что бы он поддерживал директиву #using

Добавлено: 16 фев 2005, 11:24
Romeo
Иван Михайлов, лучше расскажите, как вы его настроили, чтобы Visual C++ 7 .NET эту директиву не поддерживал? :)

Добавлено: 16 фев 2005, 12:36
Иван Михайлов
оч. смешно, я его ни как не настраивал, просто он пишет, что нужна директива /clr
а если ее настроить, то другие не работают.
но я недавно чего-то настроил, все вроде работает, но тормозит безбожно (это в MFC визард)

Добавлено: 16 фев 2005, 14:16
Romeo
Честное слово, никогда специально не настраивал проект для поддержки директивы using, хотя пишу и в чистом API, и в ATL, и в MFC. Чудеса, да и только, господин Иван Михайлов :)

Добавлено: 16 фев 2005, 14:27
Иван Михайлов
у тебя значит какой-то не привильный Visual C++. Настоящий Visual C не настроен для using'а. И в ATL и в MFC. В API не пробовал, но думаю, тоже нет.
Точно 7 версия у тебя? И точно .NET?

Добавлено: 16 фев 2005, 14:40
Romeo
Какие страсти :) . У меня не настоящий Visual C++ :) . Да, наверное это всё решает :) .

Ну а если серьёзно, то дело в том, что using без проблем работает и в 6-ой студии, и в 5-ой, мне на всех довелось поработать. Думаю, вопрос о версиях поднимать вообще нецелесообразно. Есть вариант, что инсталяшка битая, но опять-таки вероятность очень мала. Я даже не знаю что по этому поводу сказать.

Добавлено: 16 фев 2005, 17:00
Eugie
Господа, вы о разных using толкуете.

Иван Михайлов, #using используется для импорта метаданных (VC++ Managed Extension), требует опцию компилятора /clr. Последняя накладывает множество ограничений на использование других опций. Вот фрагмент из MSDN, ищи причину сам:
/clr Restrictions
Note the following restrictions on the use of /clr:

The use of Run-time Error Checks is not valid with /clr.

When /clr is used to compile a program that does not use Managed Extensions for C++, the following guidelines apply to the use of inline assembly:

- Inline assembly code that assumes knowledge of the native stack layout, calling conventions outside of the current function, or other low-level information about the computer may fail if that knowledge is applied to the stack frame for a managed function. Functions containing inline assembly code are generated as unmanaged functions, as if they were placed in a separate module that was compiled without /clr.

- Inline assembly code in functions that pass copy-constructed function parameters is not supported.

The vprintf Functions cannot be called from a program compiled with /clr.

The naked __declspec modifier is ignored under /clr.

The use of dllexport or dllimport on classes is not permitted under /clr.

The translator function set by _set_se_translator will affect only catches in unmanaged code. See Handling Exceptions Using Managed Extensions for C++ for more information.

The comparison of function pointers is not permitted under /clr.

The use of functions that are not fully prototyped is not permitted under /clr.

The following compiler options are not supported with /clr: /GL, /Zd, /ZI or /Z7, /ML and /MLd, /Gm, /YX, and /RTC.

When using /Zi with /clr, there are performance implications; see /Zi for more information.

Passing a wide character to a .NET Framework output routine without also specifying /Zc:wchar_t or without casting the character to __wchar_t will cause the output to appear as an unsigned short int. For example:
Console::WriteLine(L' ') // will output 32
Console::WriteLine((__wchar_t)L' ') // will output a space

/GS is ignored when compiling with /clr, unless a function is under #pragma unmanaged or if the function must be compiled to native, in which case the compiler will generate warning C4793, which is off by default.

See /ENTRY for function signature requirements of a managed application.

Functions that take a variable number of arguments (varargs) will be generated as native functions. Any managed data types in the variable argument position will be marshaled to native types. Note that System::String* types are actually wide-character strings, but they are marshaled to single-byte character strings. So if a printf specifier is %S (wchar_t*), it will marshal to a %s string instead.

Добавлено: 16 фев 2005, 17:13
Romeo
Именно этот using я и имел ввиду. А что есть вариации?

Добавлено: 16 фев 2005, 17:16
Eugie
Ну а если серьёзно, то дело в том, что using без проблем работает и в 6-ой студии, и в 5-ой, мне на всех довелось поработать.
Ты писал? :)

#using появился только в .NET, то бишь 7-ке (не путать с обычным using namespace)

Добавлено: 16 фев 2005, 17:22
Romeo
Во-во, верно. Ошибся.