problems in use two cliext::stack..
stack<T^>^ pfn = gcnew stack<T^>(); - compiles
stack<K^>^ pf = gcnew stack<K^>(); - 93 compile errors.
What is the problem?
USE Generics::Stack Why is the declaration of the two machines a lot of mistakes?
private: System::Void btn_add_Click(System::Object^ sender, System::EventArgs^ e)
{
fileOperation^ fw = gcnew fileOperation();
if (comboBox1->SelectedIndex == 0 )
{
flyBird^ f = gcnew flyBird();
System::Collections::Generic::Stack<flyBird^>^ p = gcnew System::Collections::Generic::Stack<flyBird^>();
f->birdName=txt_name->Text;
f-> year = textBox1->Text;
f->vess = txt_tmp1->Text;
f->sreda = txt_tmp2->Text;
p->Push(f);
}
else
{
System::Collections::Generic::Stack<noflyBird^>^ p1 = gcnew System::Collections::Generic::Stack<noflyBird^>();
noFlyBird^ f = gcnew noFlyBird();
fn ->birdName=txt_name->Text;
fn ->year = textBox1->Text;
fn ->pitanie = txt_tmp1->Text;
fn ->domoshnie = txt_tmp2->Text;*/
}
}
Warning 1 warning C4138: '*/' found outside of comment c:\documents and settings\bobilev\my documents\visual studio 2010\projects\burd\burd\Form1.h 275 1 burd
Error 6 error C2143: syntax error : missing ';' before '}' \my documents\visual studio 2010\projects\burd\burd\Form1.h 277 1 burd
Error 7 error C2143: syntax error : missing ';' before '}' ments\visual studio 2010\projects\burd\burd\Form1.h 281 1 burd
Error 11 error C2143: syntax error : missing ';' before '}' my documents\visual studio 2010\projects\burd\burd\Form1.h 293 1 burd
Error 12 error C2143: syntax error : missing ';' before '}' c:\my documents\visual studio 2010\projects\burd\burd\Form1.h 297 1 burd
Looking at the compile errors you have, the first is an extra */ end comment without a /* to begin the comment. We can see that in the code you posted, at the end of the else block. That error is on line 275 of your code. The other compile errors you posted are on line 277 and later, so it looks like the problem is AFTER the code you posted here.
Related
yesterday I updated my Vue project to the latest Bootstrap version (5.2) and now I have a SASS Error while starting.
ERROR Failed to compile with 1 error 10:45:42
error in ./src/assets/scss/config/modern/app.scss
Syntax Error: SassError: argument `$color` of `red($color)` must be a color
on line 185 of node_modules/bootstrap/scss/_functions.scss, in function `red`
from line 185 of node_modules/bootstrap/scss/_functions.scss, in function `luminance`
from line 174 of node_modules/bootstrap/scss/_functions.scss, in function `contrast-ratio`
from line 159 of node_modules/bootstrap/scss/_functions.scss, in function `color-contrast`
from line 7 of node_modules/bootstrap/scss/_accordion.scss
from line 29 of node_modules/bootstrap/scss/bootstrap.scss
from line 15 of src/assets/scss/config/modern/bootstrap.scss
from line 19 of src/assets/scss/config/modern/app.scss
>> "r": red($color),
It's about this code snippet:
// File: _functions.scss
// Return WCAG2.1 relative luminance
// See https://www.w3.org/TR/WCAG/#dfn-relative-luminance
// See https://www.w3.org/TR/WCAG/#dfn-contrast-ratio
#function luminance($color) {
$rgb: (
"r": red($color),
"g": green($color),
"b": blue($color)
);
#each $name, $value in $rgb {
$value: if(divide($value, 255) < .03928, divide(divide($value, 255), 12.92), nth($_luminance-list, $value + 1));
$rgb: map-merge($rgb, ($name: $value));
}
#return (map-get($rgb, "r") * .2126) + (map-get($rgb, "g") * .7152) + (map-get($rgb, "b") * .0722);
}
And that's the trigger:
// File: _accordion.scss
// scss-docs-start accordion-css-vars
--#{$prefix}accordion-color: #{color-contrast($accordion-bg)};
I know, the error says, the function gets a wrong parameter, which is not of type color, but I never user it my self.
How can I fix this error and why does it occur?
What is the output of the Java program?
int a=10;
if(a==9)
System.out.println("OK ");
System.out.println("MASTER");
else
System.out.println("BYE");
It gives you error
$javac HelloWorld.java
HelloWorld.java:12: error: 'else' without 'if'
else
^
1 error
You can put braces like
int a=10;
if(a==9){
System.out.println("OK ");
System.out.println("MASTER");
}
else
System.out.println("BYE");
To get output
BYE
I'm writing my first odb code and can't get this basic working, although only the db connection code works:
/*! #file overview_record.h
*/
#ifndef OVERVIEW_RECORD_H
#define OVERVIEW_RECORD_H
#include <string>
#include <odb/core.hxx>
#include <odb/nullable.hxx>
#pragma db object table("mddb_overview") no_id
class overview_record
{
public:
#pragma db column("product_name") type("nvarchar(64)")
std::wstring product_name;
#pragma db column("order_number") type("int")
long order_number;
};
#endif
driver code:
// odb_playground.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <memory>
#include <thread>
#include <odb/core.hxx>
#include <odb/database.hxx>
#include <odb/mssql/database.hxx>
#include <odb/mssql/connection-factory.hxx>
#include <odb/mssql/exceptions.hxx>
#include "overview_record-odb.hxx"
int main(int argc, char* argv[])
{
try{
std::auto_ptr<odb::mssql::connection_pool_factory> connection_factory(
new odb::mssql::connection_pool_factory(0, std::thread::hardware_concurrency()));
std::unique_ptr<odb::database> db(
new odb::mssql::database("dsn=mddb_local_32", odb::mssql::isolation_read_committed, static_cast<SQLHENV>(0), connection_factory)
);
odb::transaction t(db->begin());
db->query<overview_record>();
//odb::result<overview_record> result();
//auto it = result.begin();
//while(true)
//{
// static int i = 0;
// if (i++ > 10)
// break;
// std::cout << "Order_number " << it->order_number << " product_name " << it->product_name << std::endl;
// ++i;
//}
t.commit();
}
catch (const odb::database_exception &e) {
std::cout << "ODB database error: " << e.what() << std::endl;
}
return 0;
}
Of course I odb-compiled the overview_record.h with odb.exe --database mssql overview_record.h (otherwise there won't be an .hxx). But I get the following compiler errors by the line db->query<overview_record>();, although instantiating a default constructed result works:
Error 3 error C2504: 'odb::result_base' : base class undefined c:\users\klm\downloads\libodb-2.4.0\odb\result.hxx 76 1 odb_playground
Error 4 error C2027: use of undefined type 'odb::result_base' c:\users\klm\downloads\libodb-2.4.0\odb\result.hxx 82 1 odb_playground
Error 5 error C2146: syntax error : missing ';' before identifier 'value_type' c:\users\klm\downloads\libodb-2.4.0\odb\result.hxx 82 1 odb_playground
Error 6 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\klm\downloads\libodb-2.4.0\odb\result.hxx 82 1 odb_playground
Error 7 error C2602: 'odb::result::value_type' is not a member of a base class of 'odb::result' c:\users\klm\downloads\libodb-2.4.0\odb\result.hxx 82 1 odb_playground
Error 8 error C2868: 'odb::result::value_type' : illegal syntax for using-declaration; expected qualified-name c:\users\klm\downloads\libodb-2.4.0\odb\result.hxx 82 1 odb_playground
Error 9 error C2027: use of undefined type 'odb::result_base' c:\users\klm\downloads\libodb-2.4.0\odb\result.hxx 93 1 odb_playground
Error 10 error C2146: syntax error : missing ';' before identifier 'result_impl_type' c:\users\klm\downloads\libodb-2.4.0\odb\result.hxx 93 1 odb_playground
Error 11 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\klm\downloads\libodb-2.4.0\odb\result.hxx 93 1 odb_playground
Error 12 error C2602: 'odb::result::result_impl_type' is not a member of a base class of 'odb::result' c:\users\klm\downloads\libodb-2.4.0\odb\result.hxx 93 1 odb_playground
Error 13 error C2868: 'odb::result::result_impl_type' : illegal syntax for using-declaration; expected qualified-name c:\users\klm\downloads\libodb-2.4.0\odb\result.hxx 93 1 odb_playground
Problem was a missing flag of the odb compiler, in this case the -q e.g. --generate-query flag. Otherwise odb won't add the needed code to the generated files.
So the correct invocation would be odb.exe -q --database mssql overview_record.h
I'm very new to ANTLR4 and am trying to build my own language. So my grammar starts at
program: <EOF> | statement | functionDef | statement program | functionDef program;
and my statement is
statement: selectionStatement | compoundStatement | ...;
and
selectionStatement
: If LeftParen expression RightParen compoundStatement (Else compoundStatement)?
| Switch LeftParen expression RightParen compoundStatement
;
compoundStatement
: LeftBrace statement* RightBrace;
Now the problem is, that when I test a piece of code against selectionStatement or statement it passes the test, but when I test it against program it fails to recognize. Can anyone help me on this? Thank you very much
edit: the code I use to test is the following:
if (x == 2) {}
It passes the test against selectionStatement and statement but fails at program. It appears that program only accepts if...else
if (x == 2) {} else {}
Edit 2:
The error message I received was
<unknown>: Incorrect error: no viable alternative at input 'if(x==2){}'
Cannot answer your question given the incomplete information provided: the statement rule is partial and the compoundStatement rule is missing.
Nonetheless, there are two techniques you should be using to answer this kind of question yourself (in addition to unit tests).
First, ensure that the lexer is working as expected. This answer shows how to dump the token stream directly.
Second, use a custom ErrorListener to provide a meaningful/detailed description of its parse path to every encountered error. An example:
public class JavaErrorListener extends BaseErrorListener {
public int lastError = -1;
#Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine,
String msg, RecognitionException e) {
Parser parser = (Parser) recognizer;
String name = parser.getSourceName();
TokenStream tokens = parser.getInputStream();
Token offSymbol = (Token) offendingSymbol;
int thisError = offSymbol.getTokenIndex();
if (offSymbol.getType() == -1 && thisError == tokens.size() - 1) {
Log.debug(this, name + ": Incorrect error: " + msg);
return;
}
String offSymName = JavaLexer.VOCABULARY.getSymbolicName(offSymbol.getType());
List<String> stack = parser.getRuleInvocationStack();
// Collections.reverse(stack);
Log.error(this, name);
Log.error(this, "Rule stack: " + stack);
Log.error(this, "At line " + line + ":" + charPositionInLine + " at " + offSymName + ": " + msg);
if (thisError > lastError + 10) {
lastError = thisError - 10;
}
for (int idx = lastError + 1; idx <= thisError; idx++) {
Token token = tokens.get(idx);
if (token.getChannel() != Token.HIDDEN_CHANNEL) Log.error(this, token.toString());
}
lastError = thisError;
}
}
Note: adjust the Log statements to whatever logging package you are using.
Finally, Antlr doesn't do 'weird' things - just things that you don't understand.
Good day!
I runned exapmles MyFirstDll and FaceAnalysis. They work fine and now i want to create dll with PSDK functionality.
PercDll.cpp:
extern "C++" CALLBACKPROC_API void Start(void)
{
MainCore* core_ = new MainCore();
core_->ToGo();
}
MainCore.h:
class MainCore
{
public:
MainCore() { }
int ToGo()
{
UtilPipeline* pipeline = new UtilPipeline(); /* 1 */
return 0;
}
};
If i commit string /* 1 / all builds and works fine. But when i uncommit string / 1 */ i look errors:
Error 1 error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all#_Container_base12#std##QAEXXZ) already defined in libpxcutils_d.lib(util_pipeline_raw.obj) c:\Users\i\documents\visual studio 2010\Projects\Perceptual10\Perceptual10\msvcprtd.lib(MSVCP100D.dll)
Error 2 error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12#std##QAE#XZ)already defined in libpxcutils_d.lib(util_pipeline_raw.obj) c:\Users\i\documents\visual studio 2010\Projects\Perceptual10\Perceptual10\msvcprtd.lib(MSVCP100D.dll)
Error 4 error LNK1169: one or more multiply defined symbols found c:\users\i\documents\visual studio 2010\Projects\Perceptual10\Debug\Perceptual10.dll 1
What's this? I am searching the solution for a long time. Help please to fix it.
Thank you!