Ошибка компилятора c3699

description title ms.date f1_keywords helpviewer_keywords ms.assetid

Learn more about: Compiler Error C3699

Compiler Error C3699

11/04/2016

C3699

C3699

47c29afc-ab8b-4238-adfe-788dd6e00b3b

Compiler Error C3699

‘operator’ : cannot use this indirection on type ‘type’

An attempt was made to use indirection that is not allowed on type.

Examples

The following sample generates C3699.

// C3699.cpp
// compile with: /clr /c
using namespace System;
int main() {
   String * s;   // C3699
   // try the following line instead
   // String ^ s2;
}

A trivial property cannot have reference type. See property for more information. The following sample generates C3699.

// C3699_b.cpp
// compile with: /clr /c
ref struct C {
   property System::String % x;   // C3699
   property System::String ^ y;   // OK
};

The equivalent of a «pointer to a pointer» syntax is a handle to a tracking reference. The following sample generates C3699.

// C3699_c.cpp
// compile with: /clr /c
using namespace System;
void Test(String ^^ i);   // C3699
void Test2(String ^% i);

I am trying to compile a managed cpp(/clr) project. The code is as follows:

#include "stdafx.h"

class TestClass
{
public:
    //virtual ~TestClass() {}
    virtual void func() {}

    System::ConsoleColor color;
};

class Helper
{
public:
    static TestClass Help()
    {
        TestClass a;
        return a;
    }
};

int main()
{
    Helper::Help();
    return 0;
}

It fails to compile with following error

error C3699: ‘&&’: cannot use this indirection on type
‘System::ConsoleColor’

If I add a trivial destructor (virtual or non-virtual) or I convert the function func() to non-virtual the compiler error is gone. Can someone explain the behavior.
Also the compiler error happens on VS2015 and VS2017 but not on VS2013.

cjv

0 / 0 / 1

Регистрация: 20.07.2017

Сообщений: 15

1

09.08.2018, 10:34. Показов 3344. Ответов 7

Метки нет (Все метки)


Студворк — интернет-сервис помощи студентам

У меня есть форма MainForm и библиотека cyplib.h внутри одного проекта. Я хочу использовать функции из библиотеки при работе с моей формой. Для этого я пытаюсь включить библиотеку в MainForm.h или в MainForm.cpp. Но как только я куда-то её включаю, сразу же появляются ошибки в MainForm.cpp

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "MainForm.h"
#include "cyplib.h"
 
using namespace System;
using namespace System::Windows::Forms;
 
[STAThreadAttribute]
int main(array < String^> ^ args) {
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false);
    Cipher::MainForm form;
    Application::Run(%form);
    return 0;
}

Ошибка C2976 std::array: слишком мало аргументов шаблон Cipher c:usersusersourcereposcipherciphermainform.cpp 8

Ошибка C3699 ^: это косвенное обращение невозможно использовать для типа «std::array» Cipher c:usersusersourcereposcipherciphermainform.cpp 8

Что с этим делать?



0



OwenGlendower

Администратор

Эксперт .NET

15621 / 12590 / 4990

Регистрация: 17.03.2014

Сообщений: 25,584

Записей в блоге: 1

09.08.2018, 11:49

2

Лучший ответ Сообщение было отмечено cjv как решение

Решение

cjv,

C++
9
int main(cli::array < String^> ^ args) {



1



0 / 0 / 1

Регистрация: 20.07.2017

Сообщений: 15

09.08.2018, 12:06

 [ТС]

3

Теперь всё выглядит ещё страшнее (6 предупреждений были и раньше)

Ошибки C2976 и C3699



0



Администратор

Эксперт .NET

15621 / 12590 / 4990

Регистрация: 17.03.2014

Сообщений: 25,584

Записей в блоге: 1

09.08.2018, 12:16

4

cjv, «переведи» эти сообщения с помощью декодера и действуй с в соответствии с текстом ошибок.



0



0 / 0 / 1

Регистрация: 20.07.2017

Сообщений: 15

09.08.2018, 13:15

 [ТС]

5

OwenGlendower, в общем, ему не нравились моя локализация. В одном месте я вместо L» привет « выводил в поток wcout просто » привет «.
А за cli::array огромное спасибо! Странно, что ни в одной инструкции по работе с формами, которую я видел, не сказано про это.



0



Администратор

Эксперт .NET

15621 / 12590 / 4990

Регистрация: 17.03.2014

Сообщений: 25,584

Записей в блоге: 1

09.08.2018, 13:35

6

cjv, в инструкциях об этом не пишут потому что это не имеет к отношения к формам. Это базовые правила языка которые программист уже должен знать.



0



cjv

0 / 0 / 1

Регистрация: 20.07.2017

Сообщений: 15

09.08.2018, 14:49

 [ТС]

7

Теперь у меня другая проблема. Когда я добавляю

C++
1
#include "msclrmarshal_cppstd.h"

в mainform.h или в mainform.cpp, чтобы преобразовывать System::String^ в std::wstring, возникают 11 ошибок в кодировке IBM866. Вот они в нормальной кодировке:
1>MSVCMRTD.lib(mstartup.obj) : error LNK2022: сбой операции с метаданными (80131195): Несовместимые особые атрибуты. (0x0c0001fe).
1>MSVCMRTD.lib(mstartup.obj) : error LNK2022: сбой операции с метаданными (80131195): Несовместимые особые атрибуты. (0x0c000201).
1>MSVCMRTD.lib(managdeh.obj) : error LNK2022: сбой операции с метаданными (80131195): Несовместимые особые атрибуты. (0x0c0000dd).
1>MSVCMRTD.lib(managdeh.obj) : error LNK2022: сбой операции с метаданными (80131195): Несовместимые особые атрибуты. (0x0c0000de).
1>MSVCMRTD.lib(mehvecdtr.obj) : error LNK2022: сбой операции с метаданными (80131195): Несовместимые особые атрибуты. (0x0c0000b4).
1>MSVCMRTD.lib(mehvecdtr.obj) : error LNK2022: сбой операции с метаданными (80131195): Несовместимые особые атрибуты. (0x0c0000b7).
1>MSVCMRTD.lib(msilexit.obj) : error LNK2022: сбой операции с метаданными (80131195): Несовместимые особые атрибуты. (0x0c000106).
1>MSVCMRTD.lib(msilexit.obj) : error LNK2022: сбой операции с метаданными (80131195): Несовместимые особые атрибуты. (0x0c000109).
1>MSVCMRTD.lib(pureMSILcode.obj) : error LNK2022: сбой операции с метаданными (80131195): Несовместимые особые атрибуты. (0x0c0001b9).
1>MSVCMRTD.lib(pureMSILcode.obj) : error LNK2022: сбой операции с метаданными (80131195): Несовместимые особые атрибуты. (0x0c0001bb).
1>LINK : fatal error LNK1255: не удалось выполнить компоновку из-за ошибок в метаданных

Хотя бы на этот раз ошибка не в моей библиотеке.



0



0 / 0 / 1

Регистрация: 20.07.2017

Сообщений: 15

11.08.2018, 11:05

 [ТС]

8

Оказалось, что маршалинг не поддерживается в версии .NET Framework 3.5. Грустно. Придётся искать более извращённые способы преобразования типов.



0



  • Remove From My Forums
  • Question

  • First off, I would like to say that I am quite aware that I am supposed to use » ^ » instead of » * «.

    My question is this:
    In the code below, to my knowledge, filelist creates a new object identical to xml->ChildNodes[0]. Is there a way that I can create a handle to the object xml->ChildNodes[0] instead of duplicating it? I have tried using » * » instead wich obviously brings up the C3699 compiler error, but im not sure what else to do. If it creates a copy, then any changes i make the filelist will have to be manualy copied to xml wich is what im trying to avoid.


    [code]
    using namespace System;
    using namespace System::Xml;

    String^ filename=gcnew String(«some file name»);

    XmlDocument xml=gcnew XmlDocument();
    xml->Load(filename);

    // Line in question

    XmlNode^ filelist = xml->ChildNodes[0];
    [/code]


    (i wasnt sure if there was a code tag so i simply used a monospace font)

    In the code above, i showed only the relevant lines, thats why you dont see any file or node existance checking or validation.

    Any and all directions given to solve this problem would be greatly apreciated.

Answers

  • Reference handle assignment (e.g. Object^left; Object^right; left=right ;) is  duplicating handles, not objects.  If you want to duplicate objects you have to allocate a new object.  Built-in types generally do this with with a copy c’tor (String ^ left = «left»; String ^ right = «right»; left = gcnew String(right)); more complex types usually only do a shallow copy with their copy c’tor (shallow copying meaning a new object is allocated but any references it contains only copy their reference).  If you’re interested in a deep copy of the referenced object in xml->ChildNodes[0], you’d want to use CloneNode: XmlNode ^ filelist = xml->ChildNodes[0]->CloneNode(true);

Я пытаюсь скомпилировать управляемый проект cpp (/ clr). Код выглядит следующим образом:

#include "stdafx.h"
class TestClass
{
public:
//virtual ~TestClass() {}
virtual void func() {}

System::ConsoleColor color;
};

class Helper
{
public:
static TestClass Help()
{
TestClass a;
return a;
}
};

int main()
{
Helper::Help();
return 0;
}

Не удается скомпилировать со следующей ошибкой

ошибка C3699: ‘&&’: нельзя использовать эту косвенность по типу
‘System :: ConsoleColor’

Если я добавлю тривиальный деструктор (виртуальный или не виртуальный) или преобразую функцию func () в не виртуальную, ошибка компилятора исчезнет. Может кто-нибудь объяснить поведение.
Также ошибка компилятора происходит на VS2015 и VS2017, но не на VS2013.

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

Понравилась статья? Поделить с друзьями:
  • Ошибка компилятора c3646
  • Ошибка компиляции для платы arduino uno как исправить
  • Ошибка компилятора c2995
  • Ошибка компиляции для платы arduino uno grbl
  • Ошибка компилятора c2784