SEARCH YOUR SOLUTION HERE  

Problem with user-defined IO streambuf for encoding purposes

Hi ,

I'm having some difficulty with the following piece of code. I have
stripped it to it's bare minimum to demonstrate the problem at hand.

Compiler: MS Visual C++ 2005 Express Edition (similar problem arises
with 2008)

Runtime Library: multi-threaded variants have been seen to fail
[DLL/Static] | [Debug|Release]

Purpose: define a user defined stream buffer that processes each
incoming character and translates it to an encoded value. Place the
encoded character into a local buffer for output. The most simple case
would be an encoder that translates each character to upper case. A
more complicated case would be an encoder that encodes plain-text to
base64 encoding (this is not a one-to-one character encoding, it's a 3
character to 4character encoding, this is why an internal buffer is
needed)

Problem: The code throws an "Unhandled exception at 0x00529bcc in
hsl_d.exe: 0xC0000005: Access violation reading location 0x00000000."
after the "encoderbuf::underflow c = 51" character '3' has been read.
This basically tells me that deep down in the internals of the IO
library something is being dereferenced that is not allocated.

Question(s):
1) Does this occur with other compilers (requires testing)
2) Is this a problem with the IO library (unlikely I think)
3) Am I doing something stupid (more than likely) And if so what

References:
C++ Standard Library - A Tutorial and Reference (13.13.3 User-Defined
Stream Buffers)


Code:

#include
#include

class encoderbuf : public std::streambuf {

char mCharBuf[128];
int mBufLen;
int mBufPos;
public:
//--------------------------------------------------------------
/** default constructor */
encoderbuf()
: std::streambuf()
, mBufLen(0)
, mBufPos(0)
{
}

//--------------------------------------------------------------
/** outgoing data */
virtual int_type underflow () {
int_type c = EOF;
if (mBufPos < mBufLen) {
c = mCharBuf[mBufPos++];
}
std::cout << "encoderbuf::underflow c = " << c << std::endl;

return c;
}

//--------------------------------------------------------------
/** incoming data */
virtual int_type overflow (int_type c) {
std::cout << "encoderbuf:verflow c = " << c << std::endl;
//TODO: do encoding here
mCharBuf[mBufLen++] = c;
return c;
}
};

//--------------------------------------------------------------
int main (int argc, char ** argv) {
encoderbuf buf;
std::iostream iostr(&buf);
iostr << 12345 << std::endl;
std::stringstream sstr;
iostr >> sstr.rdbuf(); // EXCEPTION AT PROCESSING CHARACTER '3'

std::string str = sstr.str();
std::cout << "main str = " << str << std::endl;
}


Output:
encoderbuf:verflow c = 49
encoderbuf:verflow c = 50
encoderbuf:verflow c = 51
encoderbuf:verflow c = 52
encoderbuf:verflow c = 53
encoderbuf:verflow c = 10
encoderbuf::underflow c = 49
encoderbuf::underflow c = 50
encoderbuf::underflow c = 51
popup: Unhandled exception at 0x00529bcc in hsl_d.exe: 0xC0000005:
Access violation reading location 0x00000000.

Posted On: Wednesday 7th of November 2012 12:51:37 PM Total Views:  349
View Complete with Replies




Related Messages:

Static constructors: a complex problem   (131 Views)
Let's suppose that, under a particular platform, the compiler doesn't initialize correctly the global constructors and destructors at startup. The compiler is psp-gcc. I have written two routines, __do_constructor_initialization_aux and __do_destructor_initialization_aux that, if recalled explictly by the code of the program, start the routines generated by the compiler and initialize the global constructors (o deinitialize the constructors when the program finish). Unfortunately, each of this routine can access only to the .ctor or .dtor section of the module in which it is compiled, not to the .ctor or .dtor section of different modules. So, if you are compiling a project in C++ that contains n files .o, **in each of these** a routine __do_constructor_initialization_aux and a routine __do_destructor_initialization_aux must be present. If the project has n object .o, there will be n __do_constructor_initialization_aux routines and n __do_destructor_initialization_aux routines. N isn't a known number, because it depends from the o. files that the programmer chooses to create. The trouble is the following: who start these routines at startup It is needed a special symbol in psp-gcc or in psp-ld that makes that, at startup, before that main () is executed, the cpu executes all initialitation routines present in each module that has been linked. Any idea
copy constructor problem   (129 Views)
On May 27, 11:07 am, ciccio wrote: > > > I have a problem and I don't know what is going on here. > > I basically call a function defined as test(const bar &a), in which I > define a const reference to an object foo which comes from bar. At this > point I have a copy constructor which should not be the case. > > A working example you can find below which explains it a bit better. > > Am I just doing something stupidly wrong here You aren't understanding that your bar:perator() is returning by value, which creates a temporary object when it returns.
A problem with templates   (152 Views)
I tried to compile some code in BCB5 SP1 and stumbled upon this issue that is exibited by a code below: #include struct mytype { mytype() {} }; template void func(T &t, T1 p1) { // } template void func(T &t, mytype &p1) { // } void exibit_error() { mytype *m = new mytype(); int p = 1; func(p,*m); //error is here delete m; } int __cdecl main(int /*argc*/, char** /*argv[]*/) { return EXIT_SUCCESS; } The code above shows this error at designated line: E2015 Ambiguity between 'func(int &,mytype)' and 'func(int &,mytype &)' Is there a way to circumvent this behavior and convince compiler to call second version of func
Does this function have memory problem?   (132 Views)
Does this function have memory problem void pushSomthingIntoVector(vector & v) { //T is a class v.assign(0, T(100)) //T(int a) is a constructor of class T v.push_back(T(50)) } void anotherFunction() { vector v; pushSomethingIntoVector(v); cout
GDB debugger problem   (141 Views)
hello , i was debugging a simple program using gdb debugger and when in function display on the simple line cout
base classes and inheritance problem   (125 Views)
, considering this code: class A { protected: int n; }; class B : public A { public: void setn(int k){ n = k;} }; int main() { A *c; c = new B(); c->setn(10); return 0; } This of course will not compile, i'm trying to avoid using virtual functions in class A and i was wondering if there exist a way of achieving something like this code.
problem with unary_compose   (221 Views)
hi i'm trying to use the "functional extensions" of the stl. having a "problem" with the unary_compose.. The following code seems right to me, but doesnt compile - if i declare "operator()" of "struct one" as const it works - but i dont understand why it has to be static .. ! #include #include #include using namespace std; using namespace __gnu_cxx; struct one: public unary_function { int operator()(int arg) { return ++arg; } }; int main(int argc, char** argv) { one o1,o2; int i = 2; unary_compose func = compose1(o1,o2); cout
problems with std and const (inspectors)   (134 Views)
Files: pirma_lib.h - http://www.paste.lt/paste/de66c8b700...19eea1318d1993 pirma_lib.cpp - http://www.paste.lt/paste/050b916516...8f54a0193fe564 pirma.cpp - http://www.paste.lt/paste/6753553152...703393d79d6f67 I am using std:: in pirma_lib everywhere and this why I do not need to use "using" and and std library which later could make some problems and it still does now. The problem is that when everything was in one file it was working perfect and now I decided to put everything in separate files. This way I made direct calls (std: and removed "using namespace std;" from pirma_lib.cpp and this worked, I was able to compile this model (g ++ -Wall -ansi -pedantic -c pirma_lib.h); But I was not able to compile the main code. Every line where I was using "Aibe" class and it's methods was returning mistakes. But after commenting "using namespace std;" in pirma.cpp I did not get any error, but I should write to every cin, cout and etc std:: (make direct calls). The question would be how I should correctly move my class to separate file, make module Why it throwing mistakes with that std (This one makes the most problems as I can see); - - - The second question. In pirma_lib.h there is a line: bool isSubSet(Aibe &other); But I would like to protect "other" Aibe instance and use "const Aibe &other", but inside it I am using length() method. (but I could easily get directly if I need). And this throws another mistake, that I can not use length() method in this case, but I then declare length: int length() cent; This should mean that length() can not change *this and I think that now it should allow me to call it, but again I am still getting mistake that it can not find such method at all. (It might be that I still does not understand how it works) Could someone explain why I can not call length() method This mistake: pirma.cpp: In member function 'bool Aibe::isSubSet(const Aibe&)': pirma.cpp:101: error: no matching function for call to 'Aibe::length() const' pirma.cpp:20: note: candidates are: int Aibe::length()
ofstream problem   (149 Views)
I'm trying to write to a text file with following code: std:fstream out("/usr/share/NovaxTSP/INITreport.txt", std::ios_base::in | std::ios_base:ut | std::ios_base::app); if(!out) { // if out couldn't be opened, print error and exit std::cout
problems about aCC   (119 Views)
* guojianlee: > I have some problem ,when compiling program in > hp 11.1 > aCC: HP ANSI C++ B3910B A.03.37 > ,just like this "aCC test.cpp". > but when i compile it with option -AA ,every thing is OK. > source code and error info as follow.who can tell me why ,thank you > very much. > > source code: > > $vi test.cpp > > #include > #include > > namespace std {} You don't need that, it serves no useful purpose. > using namespace std; Consider placing this directive inside the function where it's needed. > int main() > { > map m; > string a("11"),b("2222"); > m.insert(make_pair(a,b)); You haven't included and so you're not guaranteed to have a definition of make_pair. > } Cheers, & hth., - Alf -- A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail
function pointer problem   (151 Views)
I have a singleton class Modem namespace Proxy { Modem { .... static Modem* Instance(); Intf::ModemAlarmStatusRespMsg *GetAlarmStatusRespMsg(){return &m_alarmStatusResp;} .... } }; class BaseModemAlarmublic BaseAlarm { public: BaseModemAlarm(){}; BaseModemAlarm(const ut_int32 AlarmId){}; Intf::ModemOffOnEnum (*funcField)(); private: //MemFunc funcField; ut_int32 AlarmId; // method int GetRefValue(){return static_cast (Intf::MOD_ON);}; int GetStatusValue(){ return static_cast ( (*funcField) () ); }; }; // in constructor of another class I would like build a instance of BaseModemAlarm passing a member function. ModemAlarmHandler::ModemAlarmHandler() { BaseModemAlarm Alarm_OlBitePll(Intf::MODEM_OL_BITE_PLL_ALARM); Intf::ModemAlarmStatusRespMsg * msg=Proxy::Modem::Instance- >GetAlarmStatusRespMsg(); Alarm_OlBitePll.funcField=&(msg->GetOlBitePllAlarm); }; I would like access to msg->GetOlBitePllAlarm() at runtime from Alarm_OlBitePll instance. I get a compiler error. I can't access directly to ModemAlarmStatusRespMsg fields beacuse they are declare as private and I can't modify the class definition. I need to declare several different instance of BaseModemAlarm and for every instance I should call a different method for msg object. Please help me. Ale.
problem regarding inheritance   (160 Views)
everybody, I'm writing a COM component and don't want to put the IUnknown implementation in every COM class so I'm using inheritance. I'm getting a error 'cannot instantiate abstract class' even though all virtual methods are implemented. Can anybody tell me what I'm doing wrong thanks Frank #include "stdafx.h" #include class ComBase { public: STDMETHOD(QueryInterface)(REFIID,LPVOID*); STDMETHODIMP_(ULONG) AddRef() { return 0; } STDMETHODIMP_(ULONG) Release() { return 0; } }; class ComClass: public ComBase, public IShellExtInit { public: STDMETHOD(QueryInterface)(REFIID,LPVOID*); STDMETHOD(Initialize)(LPCITEMIDLIST, LPDATAOBJECT, HKEY); }; STDMETHODIMP ComClass::QueryInterface(REFIID riid, LPVOID *ppv) { return E_NOTIMPL; } STDMETHODIMP ComClass::Initialize( LPCITEMIDLIST pidlFolder, LPDATAOBJECT pDataObj, HKEY hProgID ) { return E_NOTIMPL; } int _tmain(int argc, _TCHAR* argv[]) { ComClass argh; return 0; }
Linkage problems with in-class static members   (137 Views)
I got a weired linkage problem, trying to initialize a member of a class with a static const. The problem could be condensed into the following little program: //file test.cpp: class T { public: static const int STATIC_MEMBER_A = 1; static const int STATIC_MEMBER_B = 2; T(int x); private: int t; }; T::T(int x): t(x > 0 STATIC_MEMBER_A: STATIC_MEMBER_B) {} int main(int argnum, char** args) { T t(-5); } //end file test.cpp I'm getting following reproducable error in linkage: /tmp/cc0UEe2g.o: In function `T::T(int)': test.cpp.text+0x13): undefined reference to `T::STATIC_MEMBER_A' test.cpp.text+0x1e): undefined reference to `T::STATIC_MEMBER_B' /tmp/cc0UEe2g.o: In function `T::T(int)': test.cpp.text+0x43): undefined reference to `T::STATIC_MEMBER_A' test.cpp.text+0x4e): undefined reference to `T::STATIC_MEMBER_B' collect2: ld returned 1 exit status I'm using g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21). If I change T::T(int x): t(x > 0 STATIC_MEMBER_A: STATIC_MEMBER_B) {} to T::T(int x): t(x > 0 STATIC_MEMBER_A: 9) {} the program can be linked and executed without any error. Is this a bug in g++ Does anybody have a clue
Some problem in using references   (150 Views)
I wrote following code for insertion sort. The code was compiled using gcc-4.1.1-30 on my fedora core 6 system. For this code output is not correct {output is 2,5,76,76,76}. It seems, "line #2" is not working. Meanwhile no problem occurs when 1. line #1 is changed to T key = arr[i]; or 2. line #2 is changed to T& q = arr[j+1]; q = key. Am I missing something
templates, typename, and basic_streambuf method return type problems   (154 Views)
I am trying to derive from the basic_streambuf, following an example in my book and am getting the following error: 1>loggerstreambuffer.hxx(32) : error C2440: 'return' : cannot convert from 'std::char_traits::int_type (__cdecl *)(void)' to 'int' I do not understand why it wants an int instead of an int_type, especially after looking over the basic_streambuf header. Is this some implementation specific thing Admitadly I do not understand the difference between a typdef and a typename and a typedef typename. I know what a typedef is just fine, but never have used a typename. I would think my class would inherit what an int_type is from the basic_streambuf. I also have no idea what the __CLR_OR_THIS_CALL macro is doing in my basic_streambuf implementation. I suspect its a MS specific thing and hope its not the problem. It appears to be doing the __cdecl. code: #ifndef LOGGERSTREAMBUFFER_HXX #define LOGGERSTREAMBUFFER_HXX #include namespace cpisz_common_lib { //---------------------------------------------------------------------------------------------------------------------- template class LoggerStreamBuffer : public std::basic_streambuf { public: /* typedef charT char_type; typedef traits traits_type; typedef typename traits::int_type int_type; typedef typename traits:os_type pos_type; typedef typename traits:ff_type off_type; */ LoggerStreamBuffer() : m_takeFromBuffer(false) { } protected: int_type overflow(int_type c = traits_type::eof()) { return traits_type::eof; } int_type uflow() { return traits_type::eof; } int_type underflow() { return traits_type::eof; } int_type pbackfail(int_type c) { return traits_type::eof; } private: /** Prevents copy construction */ LoggerStreamBuffer(const LoggerStreamBuffer &); /** Prevents assignment */ LoggerStreamBuffer & operator =(const LoggerStreamBuffer &); /** Internal buffer */ char_type m_charBuffer; bool m_takeFromBuffer; }; }// namespace cpisz_common_lib #endif instantiation: //----- // Test the LoggerStreamBuffer LoggerStreamBuffer buffer; Copy paste from my basic_streambuf header: [snip] template class basic_streambuf { [snip] virtual int_type __CLR_OR_THIS_CALL overflow(int_type = _Traits::eof()) { // put a character to stream (always fail) return (_Traits::eof()); } [snip] public: typedef basic_streambuf _Myt; typedef _Elem char_type; typedef _Traits traits_type; [snip] typedef typename _Traits::int_type int_type; typedef typename _Traits:os_type pos_type; typedef typename _Traits:ff_type off_type;
A problem about concatenation in macro   (134 Views)
I am just stumbled by a problem about concatenation in macro. See below code snippet: // there're some contants definition in this class struct X { enum {A, B, C}; }; // and here I want to define a utility macro to help me generate some functions #define MK_FUNC(arg) \ int get##arg() \ { \ return X::##arg; \ } MK_FUNC(A) MK_FUNC(B) MK_FUNC(C) #undef MKFUNC // then I can use getA(), getB() .... in my program. But the preprocessor always complains: warning: pasting "::" and "A" does not give a valid preprocessing token warning: pasting "::" and "B" does not give a valid preprocessing token warning: pasting "::" and "C" does not give a valid preprocessing token I really don't why this will happen. Isn't this usage in the macro "X::##arg" an invalid Hope someone can help me out. - Martin
bit setting problem   (111 Views)
"mataus" wrote in message news:47855e91@newsgroups.borland.com... > but code does not work if i test for two bits: Your use of the '!' operator is throwing off the comparisons, as you are inverting the bits of iFlags before the '&' operator is invoked on it. Try moving the '!' operator around, ie: if( !(iFlags & SECOND_BIT) && !(iFlags & THIRD_BIT) ) { Label1->Caption = "2 and 3 not set"; } else if( !(iFlags & SECOND_BIT) && (iFlags & THIRD_BIT) ) { Label1->Caption = "2 not set, 3 set"; } else if( (iFlags & SECOND_BIT) && !(iFlags & THIRD_BIT) ) { Label1->Caption = "2 set, 3 not set"; } else /*if( (iFlags & SECOND_BIT) && (iFlags & THIRD_BIT) )*/ { Label1->Caption = "2 and 3 set"; } Alternatively, don't use the '!' operator at all: if( ((iFlags & SECOND_BIT) == 0) && ((iFlags & THIRD_BIT) == 0) ) { Label1->Caption = "2 and 3 not set"; } else if( ((iFlags & SECOND_BIT) == 0) && (iFlags & THIRD_BIT) ) { Label1->Caption = "2 not set, 3 set"; } else if( (iFlags & SECOND_BIT) && ((iFlags & THIRD_BIT) == 0) ) { Label1->Caption = "2 set, 3 not set"; } else /*if( (iFlags & SECOND_BIT) && (iFlags & THIRD_BIT) )*/ { Label1->Caption = "2 and 3 set"; } Alternatively, when checking whether multiple bits are all set or all not set, you can combine them when using the '&' operator: if( !(iFlags & (SECOND_BIT | THIRD_BIT)) ) { Label1->Caption = "2 and 3 not set"; } else if( !(iFlags & SECOND_BIT) && (iFlags & THIRD_BIT) ) { Label1->Caption = "2 not set, 3 set"; } else if( (iFlags & SECOND_BIT) && !(iFlags & THIRD_BIT) ) { Label1->Caption = "2 set, 3 not set"; } else /*if( iFlags & (SECOND_BIT | THIRD_BIT) == (SECOND_BIT | THIRD_BIT) )*/ { Label1->Caption = "2 and 3 set"; } Or: if( (iFlags & (SECOND_BIT | THIRD_BIT)) == 0 ) { Label1->Caption = "2 and 3 not set"; } else if( ((iFlags & SECOND_BIT) == 0) && (iFlags & THIRD_BIT) ) { Label1->Caption = "2 not set, 3 set"; } else if( (iFlags & SECOND_BIT) && ((iFlags & THIRD_BIT) == 0) ) { Label1->Caption = "2 set, 3 not set"; } else /*if( iFlags & (SECOND_BIT | THIRD_BIT) == (SECOND_BIT | THIRD_BIT) )*/ { Label1->Caption = "2 and 3 set"; } Gambit , Remy Lebeau (TeamB) wrote: >Alternatively, when checking whether multiple bits are all set or all not >set, you can combine them when using the '&' operator: > > if( !(iFlags & (SECOND_BIT | THIRD_BIT)) ) > { > Label1->Caption = "2 and 3 not set"; > } > else if( !(iFlags & SECOND_BIT) && (iFlags & THIRD_BIT) ) > { > Label1->Caption = "2 not set, 3 set"; > } > else if( (iFlags & SECOND_BIT) && !(iFlags & THIRD_BIT) ) > { > Label1->Caption = "2 set, 3 not set"; > } > else > { > Label1->Caption = "2 and 3 set"; > } - or - if( iFlags & SECOND_BIT ) { if( iFlags & THIRD_BIT ) { Label1->Caption = "2 and 3 set"; }else{ Label1->Caption = "2 set, 3 not set"; }; }else{ if( iFlags & THIRD_BIT ) { Label1->Caption = "2 not set, 3 set"; }else{ Label1->Caption = "2 and 3 not set"; }; }; - or - if( CheckBox2->Checked ) { if( CheckBox3->Checked ) { Label1->Caption = "2 and 3 set"; }else{ Label1->Caption = "2 set, 3 not set"; }; }else{ if( CheckBox3->Checked ) { Label1->Caption = "2 not set, 3 set"; }else{ Label1->Caption = "2 and 3 not set"; }; };
Design problem: Factory pattern needs 'static virtual'?   (159 Views)
I need a simple object serialization, where loading an object from file looks like this: Foo* foo1 = FooFactory::create("./saved/foo1.a321f23d"); Foo* foo2 = FooFactory::create("./saved/foo2.eb287ac8"); Now, Foo is an abstract base class, and FooFactory contains a static function which again calls static create functions on Foo1 or Foo2 (see code for all classes below). The problem is that all these functions are static, but I also want them to be part of the (virtual) Foo interface. But virtual static functions are not allowed. You might say that Foo1::create(...) should not be a member function, but just a global function outside of Foo1. But I want classes derived from Foo1 to be able to inherit or override create(...). How should I design this properly
problem in OPT++(C++ optimization toolbox)   (115 Views)
I have been using OPT++ to solve a non linear programming problem. I am totally new to C++, but I looked at an example given on OPT++ website and modified it according to my problem. But I am getting some error there. Since I don't have ****ytical derivatives, I am using FDNLF1 type of problem and optimization method used is OptFDNIPS. I am getting problem in the input arguments(function, constraints etc) of FDNLF1 which I constructed the way it is done in the example on opt++ website (http://csmr.ca.sandia.gov/opt++/opt+.../example2.html). But that example uses NLF2 type of problem. Since I am totally new to C++, I have no idea what is causing these errors. The error that I am getting is : --------------------------------------------------------- ERROR MESSAGE---------------------------------------------------------------- example2.cpp: In function `int main()': example2.cpp:24: error: no matching function for call to `OPTPP::FDNLF1::FDNLF1(int&, void (&)(int, const NEWMAT::ColumnVector&, double&, int&), void (&)(int, NEWMAT::ColumnVector&), OPTPP::Constraint&)' .../OPT++/optpp-2.4/include/NLF.h:388: note: candidates are: OPTPP::FDNLF1::FDNLF1(const OPTPP::FDNLF1&) .../OPT++/optpp-2.4/include/NLF.h:425: note: OPTPP::FDNLF1::FDNLF1(int, void (*)(int, const NEWMAT::ColumnVector&, OPTPP::real&, int&, void*), void (*)(int, NEWMAT::ColumnVector&), OPTPP::CompoundConstraint*(*)(int), void*) .../OPT++/optpp-2.4/include/NLF.h:422: note: OPTPP::FDNLF1::FDNLF1(int, void (*)(int, const NEWMAT::ColumnVector&, OPTPP::real&, int&, void*), void (*)(int, NEWMAT::ColumnVector&), void*) .../OPT++/optpp-2.4/include/NLF.h:419: note: OPTPP::FDNLF1::FDNLF1(int, void (*)(int, const NEWMAT::ColumnVector&, OPTPP::real&, int&, void*), void (*)(int, NEWMAT::ColumnVector&), OPTPP::CompoundConstraint*, void*) .../OPT++/optpp-2.4/include/NLF.h:415: note: OPTPP::FDNLF1::FDNLF1(int, int, void (*)(int, const NEWMAT::ColumnVector&, NEWMAT::ColumnVector&, int&), void (*)(int, NEWMAT::ColumnVector&)) .../OPT++/optpp-2.4/include/NLF.h:411: note: OPTPP::FDNLF1::FDNLF1(int, void (*)(int, const NEWMAT::ColumnVector&, OPTPP::real&, int&), void (*)(int, NEWMAT::ColumnVector&), OPTPP::CompoundConstraint*(*)(int)) .../OPT++/optpp-2.4/include/NLF.h:407: note: OPTPP::FDNLF1::FDNLF1(int, void (*)(int, const NEWMAT::ColumnVector&, OPTPP::real&, int&), void (*)(int, NEWMAT::ColumnVector&), OPTPP::CompoundConstraint*) .../OPT++/optpp-2.4/include/NLF.h:405: note: OPTPP::FDNLF1::FDNLF1(int) .../OPT++/optpp-2.4/include/NLF.h:403: note: OPTPP::FDNLF1::FDNLF1() tstfcn.cpp: In function `void ineq_hs65(int, const NEWMAT::ColumnVector&, NEWMAT::ColumnVector&, int&)': tstfcn.cpp:86: error: invalid operands of types `double' and `double' to binary `operator^' tstfcn.cpp:90: error: invalid operands of types `double' and `double' to binary `operator^' tstfcn.cpp:93: error: invalid operands of types `double' and `double' to binary `operator^' tstfcn.cpp:95: error: invalid operands of types `double' and `double' to binary `operator^' tstfcn.cpp:96: error: invalid operands of types `double' and `double' to binary `operator^' tstfcn.cpp:100: error: invalid operands of types `double' and `double' to binary `operator^' tstfcn.cpp:103: error: invalid operands of types `double' and `double' to binary `operator^' tstfcn.cpp:105: error: invalid operands of types `double' and `double' to binary `operator^' -------------------------------------------- END OF ERROR MESSAGE ----------------------------------------------------------------- Is there anyone who has used this package(OPT++) and solved a non- linear problem(non-linear objfun and constraints) without ****ytical gradients. I would appreciate any help in this regard. Even an example code for a general non-linear problem will help. Thank you
DLL Entry point problem - Dll compiles but throws error when ran   (193 Views)
I've written a simple dll in C++ which basically right now just consists of a function to create an object, another function to check if an object has been created or not, and finally a function to destroy the object. The create, and Exists functions work fine, I added the destroy function and the DLL was built fine, no errors, not even a warning. Then I tried to access the destroy function of the dll and got this message "The procedure entry point _myproject_Destroy could not be located in the dynamic link library Mmyproject" (myproject substituted for the actual name for privacy reasons). I recognize this as a standard Windows error message when there's a dll problem but I can't figure out what it is. Any ideas I'm accessing the destroy function the exact same way as the create and exists function, I've double checked spelling and everything.