Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

piul

@piul
About
Posts
91
Topics
36
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Undeclared identifier in API
    P piul

    well... the application in which I use the lib won't compile, will it?? Or am I missing something? Including param.h in libApi.cpp, when compiling the application

    //MyApp.cpp
    #include "libApi.h"
    //library links with this
    void main (void)
    {
    //...
    }

    I get an error saying "libApi.h: 'Param' undeclared identifier"

    C / C++ / MFC help c++ json question

  • Undeclared identifier in API
    P piul

    Hi all, I'm working on a library of which I only want to distribute the .lib and a .h. The header defines the interface or api to the library, the idea being that the user does not bother much about the insides of it. However, I have a concept issue.

    //libApi.h
    #include #include class MyApiClass{
    public:
    //some methods...
    private:
    // var map
    std::map vars;
    };

    Obviously this throws an error saying Param is not defined when I compile another application that includes libApi.h and links the library. The thing is, the class Param is declared in Param.h and defined in Param.cpp, files that I don't want the user to play with. What are my options?? Thanks in advance. paul.

    C / C++ / MFC help c++ json question

  • Apparently different behaviour assigning C string to std::string, for Relese/Debug
    P piul

    It is, quite probably. fgets (not std::string constructor as I initially posted) is behaving different if I set different options for Optimization and Runtime Library in MSVS2005. I can't make Release work like Debug though, even setting the same options.

    C / C++ / MFC debugging announcement

  • Apparently different behaviour assigning C string to std::string, for Relese/Debug
    P piul

    My excuses for not answering during the weekend. As suggested by some comment on the link you posted (thank you) the problem seems to be in the fgets function. It is storing senseless data in buff for Release, and then the std::string constructor can't make sense of it. I will try with std::getline().

    C / C++ / MFC debugging announcement

  • Apparently different behaviour assigning C string to std::string, for Relese/Debug
    P piul

    Hi, I think I'm getting different behaviours with the code below for Release and Debug compiles.

    FILE* in ;
    err = fopen_s (&in, fileName.c_str(), "r");
    if (!in) {
    std::cerr << "cannot open input file '" << fileName << "'" << std::endl;
    return;
    }
    char buff[1024];
    while (fgets(buff, 1024, in)) {

    std::string line=buff;
    

    //...

    line is getting the characters ok when compiled in Debug. In Release though, line is BadPtr. I guess I'm doing the initialization wrong, but I don't see why.

    C / C++ / MFC debugging announcement

  • How to design (and do I want) an API?
    P piul

    Thanks Espen. I'll take a look at Boost.PropertyTree I didn't get what you meant by

    Espen Harlinn wrote:

    Normally you would create a class that is able to hold more than one configuration entry, and then something representing the various kinds of entries.

    C / C++ / MFC graphics design json help tutorial

  • How to design (and do I want) an API?
    P piul

    Hi, I'm working on a small libarary that will parse and modify a certain type of configuration file. As suggested by wise people (I think) I'd like to hide away the implementation and offer the user a set of functions to use the library. I have questions mainly philosophical or concerning style. I'll put here my idea and it'd be very nice to get your opinions on it.

    #ifndef CONFIGFILEAPI_H_INCLUDED
    #define CONFIGFILEAPI_H_INCLUDED

    #include
    #include

    namespace cfgFileLib
    {
    //open and parse a file
    // Returns:
    // empty string "" if succesful
    // error description if not
    std::string openConfigFile (const std::string & fileName);

    //check if a symbol is defined
    bool isDefined (const std::string & symbol);

    //how many values are assigned this symbol
    int howMany (const std::string & symbol);

    //get first (or only) value assigned to the given symbol
    bool getBool (const std::string & symbol);
    int getInt (const std::string & symbol);
    double getDouble (const std::string & symbol);
    std::string getString (const std::string & symbol);

    //get all the values assgined to the given symbol
    std::vector getAllBool (const std::string & symbol);
    std::vector getAllInt (const std::string & symbol);
    std::vector getAllDouble (const std::string & symbol);
    std::vector getAllString (const std::string & symbol);
    }
    #endif

    - Does this design make sense in general? - Do I put it all whithin a namespace?

    C / C++ / MFC graphics design json help tutorial

  • STL Containers store a copy?
    P piul

    thanks!

    C / C++ / MFC question c++ docker

  • STL Containers store a copy?
    P piul

    Hello! My question is, do STL containers store a copy or they keep the object itself? Hence, can I insert a local variable into a container?

    typedef struct{
    int number;
    string name; } myData;
    class myClass{
    void InsertData(myData &a);
    void oneFunction ();
    void otherFunction ();
    collection m_memberCollection;
    };
    void oneFunction() {
    myData localData;
    localData.name = "Paul";
    InsertData(localData);
    }
    void myClass::InsertData (myData &a){
    a.number = 5;
    m_memberCollection.push_back(a);
    }
    void otherFunction (){
    printf ("%s %d", m_memberCollection[0].name.c_str(), m_memberCollection[0].number);
    }

    Or do I need to use a collection of the type collection<*myData>?

    C / C++ / MFC question c++ docker

  • Maintenance - How to update ext app's dll dirs
    P piul

    Thanks for the reply. The problem is the other application is a propietary piece of software (some mathematical calculation), and therefore I cannot distribute it along with my application. The user will be required to copy all the dlls (the license of which he's got separately) to the application's dir. Or maybe the installation program will do that, I'm not sure yet. Could a solution be, an installer that asks for the location of the dlls and then copies them? So when the new version comes you would only need to reinstall?..

    Windows API tutorial question announcement help workspace

  • Maintenance - How to update ext app's dll dirs
    P piul

    I am not sure if this question should go here... I have an application that makes use of several libraries (dll and lib) of another application that will most probably change in the future. The problem I´m facing is how to update my application so it looks for the new libraries in the new directories. For example: currently when building the solution (MSVS2005) the directories are specified in the properties Additional dependencies: \ExtApp_1_0\LibDir, Additional Include Directories: \ExtApp_1_0\Include. How to change this to \ExtApp_2_0\LibDir and \ExtApp_2_0\Include? The solutions I can think of are: 1. Distribute the code (it´ll be distributed anyway) with a recompile manual, explaining how to change dirs manually and rebuild. - Not so nice. 2. Create a .bat file that asks the new paths and performs the rebuild. - Tried it, found it too complicated. 3. Retrieve the libraries at runtime. The setup program asks for the dirs. Reinstall when a new version comes up - I supposse possible with the dlls? how? I´m not asking for a solution, just some ideas. Anything helps! :)

    Windows API tutorial question announcement help workspace

  • std::string to System::String conversion
    P piul

    Fair enough. That's what I'd done, but... am I not re-allocating memory without freeing it first?? (I have to do it for a dozen of strings!)

    Managed C++/CLI tutorial

  • std::string to System::String conversion
    P piul

    Tried it, no good. error C2664: 'void System::Windows::Forms::Control::Text::set(System::String ^)' : cannot convert parameter 1 from 'const char *' to 'System::String ^'

    Managed C++/CLI tutorial

  • std::string to System::String conversion
    P piul

    Hi, I have

    System::String ^ St = gcnew System::String("Hey ho!");
    //...
    std::string str("standard");

    St = str; //This line won't work, but it's what I'd like to achieve

    The only way I can make it work is by doing gcnew again St = gcnew System::String(str.c_str()); but I'm guessing this is not the right way. All the examples I have found tell how to do this when creating a new instance of System::String but none how to do it with an existing one.

    Managed C++/CLI tutorial

  • Process::HasExited always true
    P piul

    Well... I was trying to make a joke, nothing else. I´m sorry if that dissapointed someone.

    .NET (Core and Framework) csharp com question

  • Process::HasExited always true
    P piul

    Am I the only fool using .NET in here?... haha In the process I´ve explained here the property Process::HasExited is true from the moment the process starts. The same occurs with the method void extProcessWorkCompleted (System::Object^ /*sender*/, System::ComponentModel::RunWorkerCompletedEventArgs^ e) which is called when the process starts, and not when it actually finishes. Has this something to do with the process´s code or am I doing something wrong?

    .NET (Core and Framework) csharp com question

  • Accessing control from a different thread
    P piul

    Maybe using http://msdn.microsoft.com/en-us/library/ms171728.aspx

    .NET (Core and Framework) winforms help tutorial

  • Accessing control from a different thread
    P piul

    I have a time consuming process that is called from a Windows forms application and run asynchronously in another thread, when the user clicks on runButton

    extProcess = gcnew System::Diagnostics::Process;
    extProcess->StartInfo = gcnew System::Diagnostics::ProcessStartInfo;
    extProcess->StartInfo->RedirectStandardOutput = true;
    extProcess->StartInfo->UseShellExecute = false; //Necessary to redirect
    extProcess->StartInfo->FileName = EXTPROC_EXE;
    extProcess->StartInfo->CreateNoWindow = true; //Don't open a new window for Process
    extProcess->OutputDataReceived += gcnew System::Diagnostics::DataReceivedEventHandler (this, &Form1::StdoutHandler);
    try
    {
    extProcessThread->RunWorkerAsync();

    The thread is launched and the standard output is read, to be shown in real time in a textBox in the main window

    void extProcessThreadDoWork (System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e)
    {
    extProcess->Start();
    extProcess->BeginOutputReadLine();
    }
    void Form1::StdoutHandler (Object ^ sender,
    System::Diagnostics::DataReceivedEventArgs ^output)
    {
    //Get text
    textBox->AppendText (output->Data + "\n");
    }

    The problem comes in this last line. An exception is launched "Control accessed from a thread other than the thread it was created on" I do understand why, but I don´t know how to solve it...

    .NET (Core and Framework) winforms help tutorial

  • External process stops everything else
    P piul

    Cheers for that!

    .NET (Core and Framework) winforms debugging question

  • External process stops everything else
    P piul

    Changed the delegate to

    void superMinerThreadWorkCompleted (System::Object^ sender,
    System::ComponentModel::RunWorkerCompletedEventArgs^ e)
    {}

    and still got the same error 'void SuperMinerGUI::Form1::superMinerThreadWorkCompleted(System::Object ^,System::ComponentModel::RunWorkerCompletedEventArgs ^)' : the specified function does not match the delegate type 'void (System::Object ^,System::ComponentModel::RunWorkerCompletedEventArgs ^)' 1&gt;Form1.cpp

    .NET (Core and Framework) winforms debugging question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups