GeoStrong 0 / 0 / 0 Регистрация: 16.04.2021 Сообщений: 25 |
||||
1 |
||||
27.06.2021, 16:49. Показов 12019. Ответов 3 Метки c++ (Все метки)
Выдаёт ошибку E0169 «требуется объявление» в строке 11 и 26.Как решить эту проблему?
0 |
DrOffset 18159 / 9492 / 2322 Регистрация: 30.01.2014 Сообщений: 16,597 |
||||
27.06.2021, 17:12 |
2 |
|||
РешениеGeoStrong, что-то у вас тут количество ошибок зашкаливает
2 |
0 / 0 / 0 Регистрация: 16.04.2021 Сообщений: 25 |
|
27.06.2021, 17:15 [ТС] |
3 |
Большое спасибо
0 |
Вездепух 11087 / 6054 / 1651 Регистрация: 18.10.2014 Сообщений: 15,183 |
|
27.06.2021, 19:43 |
4 |
Как решить эту проблему? В первую очередь: попытаться скомпилировать свой код и начать исправление ошибок с самой первой.
Выдаёт ошибку E0169 «требуется объявление» в строке 11 и 26. Нет не выдает. Во-первых, самая первая ошибка у вас совсем другая. Во-вторых, коды ошибок в вашем компиляторе начинаются с C, а не с E. E — это не «ошибки», а подсказки intellisense.
1 |
For your main error, you cannot have logical statements (if
, while
, etc.) outside of a function body. You will need to move all of your if
statements into your main
function body.
C++ uses the main
function as the «entry point» for your program, which means once all global variables, class definitions, and more, are settled, the main
function will be what your program begins to execute. All the logic for your program should always be inside of a function.
Also, as others in the comments have pointed out, you cannot choose between two values in an or
statement like you are currently doing. You need to explicitly make two comparisons. I’ve moved your conditional logic as well as changed your or
statements here, as well as added some more newlines:
#include <iostream>
using namespace std;
int computerChoiceInteger = 1 + (rand() % 3);
int main() {
if (computerChoiceInteger == 1) {
cout << "1\n";
}
if (computerChoiceInteger == 2) {
cout << "2\n";
}
if (computerChoiceInteger == 3) {
cout << "3\n";
}
cout << "Rock, paper or scissor?\n";
cout << "R=Rock P=Paper S=Scissor\n";
string rockPaperScissor;
cin >> rockPaperScissor;
if (rockPaperScissor == "r" || rockPaperScissor == "R") {
cout << "correct\n";
}
if (rockPaperScissor == "p" || rockPaperScissor == "P") {
cout << "correct\n";
}
if (rockPaperScissor == "s" || rockPaperScissor == "S") {
cout << "correct\n";
}
return 0;
}
As further reading, you may be interested in Generate random number between 1 and 3 in C++ to generate a more truly random choice by the computer.
- Remove From My Forums
-
Вопрос
-
I copied this
code and put it in my C++ project. The following is a fragment of this code:HRESULT hr = pSource->CreatePresentationDescriptor(&pPresentation); if (SUCCEEDED(hr)) { hr = pPresentation->GetStreamDescriptorCount(&cStreams); } if (SUCCEEDED(hr)) { for (DWORD iStream = 0; iStream < cStreams; iStream++) { hr = pPresentation->GetStreamDescriptorByIndex( iStream, &fSelected, &pStreamDesc);
The first if is red highlighted with a tooltip message:
expected a declaration. What declaration?The second if is NOT highlighted. Why?
Thanks, — MyCatAlex
-
Изменено
28 апреля 2019 г. 19:08
-
Изменено
Ответы
-
1. if Visual Studio IDE does not number lines, you can enable this in settings or use Control+G to jump to line.
2. This still does not loot like compiler errors
3. No offense, but the code snippet is too far from being okay. Let me suggest you a few hints to kick start. The code snippets you copy pasted from MSDN make sense but you don’t know where to insert them correctly. So maybe you should rather start from
a working sample. There are a few of them.— you can get MSDN MF samples from git https://github.com/Microsoft/Windows-classic-samples/tree/master/Samples/Win7Samples/multimedia/mediafoundation
— a few older samples are mirrored here https://github.com/roman380/msdnblogsmfsamples
If you find a close sample project it would be eathier for you to add new code on top of already working project.
http://alax.info/blog/tag/directshow
-
Помечено в качестве ответа
MyCatAlex
28 апреля 2019 г. 22:13
-
Помечено в качестве ответа
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Comments
hey, thanks for this addon. I just discovered this new protocol, and very curious about Score too.
This are the error I am getting:
Severity Code Description Project File Line Suppression State Error (active) E1696 cannot open source file "ossia-cpp98.hpp" example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOscQueryServer.h 8 Error (active) E1696 cannot open source file "ossia-cpp98.hpp" example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 3 Error (active) E1696 cannot open source file "ossia-cpp98.hpp" example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaTypes.h 2 Error (active) E0757 overloaded function "std::chrono::duration<_Rep, _Period>::duration [with _Rep=long long, _Period=std::nano]" is not a type name example-twoServers C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\chrono 195 Error (active) E0757 variable "ofxOssiaNode" is not a type name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOscQueryServer.h 44 Error (active) E0276 name followed by '::' must be a class or namespace name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOscQueryServer.h 49 Error (active) E0757 variable "ofxOssiaNode" is not a type name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOscQueryServer.h 51 Error (active) E0757 variable "ofxOssiaNode" is not a type name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOscQueryServer.h 55 Error (active) E0757 variable "ofxOssiaNode" is not a type name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOscQueryServer.h 57 Error (active) E0276 name followed by '::' must be a class or namespace name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOscQueryServer.h 62 Error (active) E0757 variable "ofxOssiaNode" is not a type name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOscQueryServer.h 65 Error (active) E0276 name followed by '::' must be a class or namespace name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 647 Error (active) E0018 expected a ')' example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 647 Error (active) E0070 incomplete type is not allowed example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 647 Error (active) E0065 expected a ';' example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 647 Error (active) E0169 expected a declaration example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 695 Error (active) E0065 expected a ';' example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 700 Error (active) E0077 this declaration has no storage class or type specifier example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 708 Error (active) E0065 expected a ';' example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 708 Error (active) E0169 expected a declaration example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 711 Error (active) E0018 expected a ')' example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 727 Error (active) E0020 identifier "default" is undefined example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 727 Error (active) E0757 variable "ofxOssiaNode" is not a type name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 728 Error (active) E0341 'operator=' must be a member function example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 728 Error (active) E0757 variable "ofxOssiaNode" is not a type name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 728 Error (active) E1774 '= default' can only appear on default constructors, copy/move constructors, copy/move assignment operators, and destructors example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 728 Error (active) E0757 variable "ofxOssiaNode" is not a type name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 729 Error (active) E0341 'operator=' must be a member function example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 729 Error (active) E0757 variable "ofxOssiaNode" is not a type name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 729 Error (active) E1774 '= default' can only appear on default constructors, copy/move constructors, copy/move assignment operators, and destructors example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 729 Error (active) E0169 expected a declaration example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 734 Error (active) E0169 expected a declaration example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 756 Error (active) E0169 expected a declaration example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 758 Error (active) E0169 expected a declaration example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 760 Error (active) E0169 expected a declaration example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 762 Error (active) E0169 expected a declaration example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 764 Error (active) E0169 expected a declaration example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 766 Error (active) E0276 name followed by '::' must be a class or namespace name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 774 Error (active) E0239 invalid specifier outside a class declaration example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 775 Error (active) E0276 name followed by '::' must be a class or namespace name example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 783 Error (active) E0169 expected a declaration example-twoServers C:\Users\myUser\Documents\openframeworks\addons\ofxOscQuery\src\ofxOssiaNode.h 820 Error C1083 Cannot open include file: 'ossia-cpp98.hpp': No such file or directory (compiling source file src\ofApp.cpp) example-twoServers c:\users\myUser\documents\openframeworks\addons\ofxoscquery\src\ofxoscqueryserver.h 8 Error C1083 Cannot open include file: 'ossia-cpp98.hpp': No such file or directory (compiling source file src\main.cpp) example-twoServers c:\users\myUser\documents\openframeworks\addons\ofxoscquery\src\ofxoscqueryserver.h 8 Warning C4018 '<': signed/unsigned mismatch example-twoServers c:\users\myUser\documents\openframeworks\addons\ofxgui\src\ofxinputfield.cpp 276 Error C1083 Cannot open include file: 'ossia-cpp98.hpp': No such file or directory (compiling source file ..\..\..\addons\ofxOscQuery\src\ofxOscQueryServer.cpp) example-twoServers c:\users\myUser\documents\openframeworks\addons\ofxoscquery\src\ofxoscqueryserver.h 8
btw, I saw your videos, and I want to ask you what’s the better Windows alternative to the OSCQueryBrowser that you are using on MacOS. Maybe should we use Vidvox/oscqueryhtml on windows?
PS: i don’t see were is:
A compiled version of libossia is included in the release.
btw, I saw your videos, and I want to ask you what’s the better Windows alternative to the OSCQueryBrowser that you are using on MacOS. Maybe should we use Vidvox/oscqueryhtml on windows?
yes, that seems like the best option that I know of (I’m not very aware of anything Windows-related, unfortunately)
PS: i don’t see were is:
A compiled version of libossia is included in the release.
did you try to build from the repository or from one of the releases ?
because the compiled lib is not on the repository, only in the releases (to keep the repo’s size small)
That’s probably what’s causing your problems above. Could you try and report back ?
Also, it’s probably better to try with the example-singleServer
And, thanks for giving it a try!
ok, thanks. I tried with this release (https://github.com/bltzr/ofxOscQuery/releases/download/1.0/ofxOscQuery-v1.0.0.zip) and it compiled rigth. I created the project with Project Generator but I had to drag ossia.lib and ossia_x64.lib manually, because they do not were into the generated project…
But when I play the Score extra demo project do not sync/makes nothing… Neither moving OF gui I see nothing linked..
On the ofxQueryDemo Score element settings I see:
ws://bltzr.local.:4677
I tried to change to localhost or Find Devices without success… I tried to change the port to 5678 too…
I will check more deeply some day. but I put this notes here because maybe it helps to clarify how to try it.
sorry for testing for this very «fast»…
Now I see that the /openframeworks/addons/ofxOscQuery/example-singleServer/client.html example is working. When moving the html sliders, ofApp receives the parameters. not backwards from OF to web
Thanks for testing @moebiussurfing !!!
Yes, the demo score is probably outdated, I should update it ASAP (no time for that today, sorry).
Would you mind creating a separate issue for that, and also one for the data not coming back to the web client ?
Concerning the Project Generator, could you please describe in further detail where it was initiallly, after running the PG, and after moving it manually ?
Thanks !
I finally found some time and just committed fixes to the Demo score, would you mind testing that again, please ?
You are welcome
Concerning the Project Generator, could you please describe in further detail where it was initiallly, after running the PG, and after moving it manually ?
I think that PG has not copied the lib anywhere. So I dragged to VS project folder and it worked.
I downloaded your new Demo.score, but stils not syncing.
The OF App logs this:
[warning] Could not set TCP nodelay option
servername: ofxOscQuery
[warning] Could not set TCP nodelay option
BTW I am not sure if I am testing it fine, because never used your Score software. What I do is to play the Score project and nothing happens to the OF App. Also tried to move OF gui sliders but nothing happens on left colum Score parameters inside myOfxOscQueryApplication folder…
Settings in Score are : ws://localhost.:5678, the same that the OF addon says is the defautl port…
Concerning the Project Generator, could you please describe in further detail where it was initiallly, after running the PG, and after moving it manually ?
This is how PG makes the project structure:
And this is how I dragged the vs compiled content folder from /libs:
This version of the addon is the release linked you sendme. The master branch addon with this lib files do not compiles.
I am running Realese/x64
I’m not sure about the whole Project Generator thing (do you still have issues with that, BTW ?)
What I know, though is that this message:
[warning] Could not set TCP nodelay option
is perfectly harmless
2 participants
ошибка C1075 — символ ‘{‘ после конца файла
|
От: |
xzibit |
|
Дата: | 27.04.09 02:12 | ||
Оценка: |
как боротся с подобной ошибкой
fatal error C1075: end of file found before the left brace '{' at 'путь до файла'
Создал Win32 -> Windows application ->empty project. Далее накидал код и вылезла подобгая ошибка.
Re: ошибка C1075 — символ ‘{‘ после конца файла
|
От: |
Bell |
|
Дата: | 27.04.09 02:42 | ||
Оценка: |
Здравствуйте, xzibit, Вы писали:
X>как боротся с подобной ошибкой
X>
X>fatal error C1075: end of file found before the left brace '{' at 'путь до файла'
X>
X>Создал Win32 -> Windows application ->empty project. Далее накидал код и вылезла подобгая ошибка.
Очевидно, забыл где-то закрывающую скобку
Попытайся выделить минимальный кусок кода, на котором эта ошибка повторяется.
Любите книгу — источник знаний (с) М.Горький
Re: ошибка C1075 — символ ‘{‘ после конца файла
|
От: |
Erop |
|
Дата: | 27.04.09 05:38 | ||
Оценка: |
2 (1) |
Здравствуйте, xzibit, Вы писали:
X>Создал Win32 -> Windows application ->empty project. Далее накидал код и вылезла подобгая ошибка.
Видимо ты в MSVC разрабатываешь?
Напиши закрывающую } в конце файла и нажми ctrl+] — увидишь незакрытую скрбку…
Все эмоциональные формулировки не соотвествуют действительному положению вещей и приведены мной исключительно «ради красного словца». За корректными формулировками и неискажённым изложением идей, следует обращаться к их автором или воспользоваться поиском
Re: ошибка C1075 — символ ‘{‘ после конца файла
|
От: |
alzt |
|
Дата: | 27.04.09 05:57 | ||
Оценка: |
Здравствуйте, xzibit, Вы писали:
X>как боротся с подобной ошибкой
X>
X>fatal error C1075: end of file found before the left brace '{' at 'путь до файла'
X>
X>Создал Win32 -> Windows application ->empty project. Далее накидал код и вылезла подобгая ошибка.
Где-то ошибся при форматировании. Посчитай количество открытых и закрытых скобок.
Re: ошибка C1075 — символ ‘{‘ после конца файла
|
От: |
jazzer |
Skype: enerjazzer |
Дата: | 27.04.09 13:49 | ||
Оценка: |
Здравствуйте, xzibit, Вы писали:
X>как боротся с подобной ошибкой
X>
X>fatal error C1075: end of file found before the left brace '{' at 'путь до файла'
X>
X>Создал Win32 -> Windows application ->empty project. Далее накидал код и вылезла подобгая ошибка.
Если у тебя есть написанные тобой заголовочные файлы, то частенько ошибка именно в них (особенно если в файле, в котором ты их подключаешь, все скобки в порядке).
Например, где-то есть #ifdef без соответствующего #endif, в результате чего закрывающая скобка не попала в компилятор.
Так что можешь попробовать закомментировать инклуды и посмотреть, изчезнет ли эта ошибка (появится, естественно, много других, но ты на них не обращай внимания до поры).
Re: ошибка C1075 — символ ‘{‘ после конца файла
|
От: |
nen777w |
|
Дата: | 27.04.09 15:05 | ||
Оценка: |
Если MSVC. Ставь Visual Assist X
Re: ошибка C1075 — символ ‘{‘ после конца файла
|
От: |
Вертер |
|
Дата: | 27.04.09 23:17 | ||
Оценка: |
1 (1) |
X>как боротся с подобной ошибкой
X>
X>fatal error C1075: end of file found before the left brace '{' at 'путь до файла'
X>
X>Создал Win32 -> Windows application ->empty project. Далее накидал код и вылезла подобгая ошибка.
могу ошибаться, но кажется такая ошибка может вылезти, если в хаголовочном файле после описания класса забудешь поставить символ «;».
Re: ошибка C1075 — символ ‘{‘ после конца файла
|
От: |
vnp |
|
Дата: | 28.04.09 05:09 | ||
Оценка: |
Здравствуйте, xzibit, Вы писали:
X>как боротся с подобной ошибкой
X>
X>fatal error C1075: end of file found before the left brace '{' at 'путь до файла'
X>
X>Создал Win32 -> Windows application ->empty project. Далее накидал код и вылезла подобгая ошибка.
Покажите файл.
———
…Очевидно, забыл где-то закрывающую скобку
…Напиши закрывающую } в конце файла и нажми ctrl+] — увидишь незакрытую скрбку
…Посчитай количество открытых и закрытых скобок.
…особенно если в файле, в котором ты их подключаешь, все скобки в порядке
Господа! у человека потеряна открывающая скобка. Пусть найдет ее, тогда и баланс можно будет считать.
Re: Это международный слёт экстрасенсов?
|
От: |
Tilir |
http://tilir.livejournal.com |
Дата: | 29.04.09 11:18 | ||
Оценка: |
3 (1) |
Сколько вариантов… ммм… сердце радуется
2xzibit: покажите уж файл, сравним чья телепатия оказалась сильнее.
Re[2]: Это международный слёт экстрасенсов?
|
От: |
dcb-BanDos |
|
Дата: | 29.04.09 14:25 | ||
Оценка: |
Здравствуйте, Tilir, Вы писали:
T>Сколько вариантов… ммм… сердце радуется
T>2xzibit: покажите уж файл, сравним чья телепатия оказалась сильнее.
уверен что вариант с
class tratata
{
}
=)
Ничто не ограничивает полет мысли программиста так, как компилятор.
Re[2]: ошибка C1075 — символ ‘{‘ после конца файла
|
От: |
dimchick |
|
Дата: | 10.05.09 23:53 | ||
Оценка: |
Здравствуйте, Erop, Вы писали:
E>Здравствуйте, xzibit, Вы писали:
X>>Создал Win32 -> Windows application ->empty project. Далее накидал код и вылезла подобгая ошибка.
E>Видимо ты в MSVC разрабатываешь?
E>Напиши закрывающую } в конце файла и нажми ctrl+] — увидишь незакрытую скрбку…
хм… нажимая ctrl+] на последней добавленной скобке меня бросает на первую открывающую скобку. Как ты выкупаешь «незакрытую скрбку» если она гдето в середине кода?
- Переместить
- Удалить
- Выделить ветку
Пока на собственное сообщение не было ответов, его можно удалить.