@ N *for sure problem is related to gcc version and qt *.... because if run other ubuntu 18.04 with gcc 5.x all work like my develop pc that contains gcc 5.5.
Any how now I have other problem related previous post ..... if(counter>=50 && counter<51) { QTextStream(stdout) << "state_msg try zone" << endl; EMC_TASK_SET_STATE *state_msg = (EMC_TASK_SET_STATE *)malloc(sizeof (EMC_TASK_SET_STATE)); QTextStream(stdout) << "spy 1" << endl; // state_msg->clear(); /* these not work because try to clear empty array? */ QTextStream(stdout) << "spy 2" << endl; state_msg->state = EMC_TASK_STATE_OFF; QTextStream(stdout) << "spy 3" << endl; state_msg->serial_number = ++emcCommandSerialNumber; QTextStream(stdout) << "actual value of state_msg: " << state_msg->state << endl; QTextStream(stdout) << "these steps seems right .. now try to write" << endl; emcCommandBuffer->write(state_msg); QTextStream(stdout) << "just write on emcCommandBuffer" << endl; free(state_msg); } counter++; get these terminal output: *state_msg try zonespy 1spy 2spy 3actual value of state_msg: 3these steps seems right .. now try to writeSegmentation error (core dump creato)* Anyone know because these row is not right? emcCommandBuffer->write(state_msg); error on malloc?? I need to call state_msg->update()?? I need to implement a function like these? int emcCommandSend(RCS_CMD_MSG & cmd) { // write command if (emcCommandBuffer->write(&cmd)) { return -1; } emcCommandSerialNumber = cmd.serial_number; return 0; } Really not know why these. Accept any suggest. Il giorno sab 28 dic 2019 alle ore 08:40 N <nicklas.karlsso...@gmail.com> ha scritto: > I would use the latest version available in whatever distribution you > happen to use but are not totally sure where sure where might be some issue > with some version. I compile Linuxcnc for myself and never thought to much > about which version of the compiler to use. > > I assume the warnings are about comppiled code then they should be there > whatever version of compiler you use. To get rid of the warnings you have > to figure out a better way to write program if possible, sometimes it's > possible but not always. If you wrote the code warnings are about you of > course have to check it to make sure there is no problem. > > > > other problem .... I try to copy my project on ubuntu 18.04 pc with gcc > 7.4 > > .... I have a lot of warning .... the major issue seems stdio.hand > cstdlib > > is not well accept from qt + gcc7.4 ..... wath is the ideal version of > gcc > > for use with Linuxcnc file? > > > > Il giorno ven 27 dic 2019 alle ore 18:47 N <nicklas.karlsso...@gmail.com > > > > ha scritto: > > > > > EMC_TASK_SET_STATE state_msg; > > > There is no malloc because memory is allocated automatically then > function > > > is entered and deallocated automatically then it exit. It is allocated > > > stack like and most probably on the stack but are not sure this is > always > > > the case. > > > > > > Local variable I consider the best method to allocate memory then it > could > > > be used for several reasons, usually most important because it is a > local > > > variable. But it also have advantage memory could be allocated with > > > increasing pointer, this is fast and deterministic. Think ADA have a > method > > > so that pointer to allocated memory is not remembered by misstake at > > > compile time but not C/C++. If you do not know what the stack is, it > is a > > > pointer to a memory set aside this purpose, then a function is called > > > adress before jump is stored on stack while stack pointer is updated > > > increased/decreased, then function exit it is the opposite order. > malloc > > > have to find a free area while stack like memory just > increase/decrease a > > > pointer but it only work for local variables in functions. > > > > > > > > > Variable is initialized by row below although I are not sure all fields > > > are initialized. Compiler may warn if it is not initialized but as I > > > remember it will not warn if some fields are unitialized. > > > state_msg.state = EMC_TASK_STATE_ESTOP; > > > > > > > > > malloc return a pointer to "void" which is more or less equivalent to > > > pointer to unknown data type which must be the reason you get "no > viable > > > conversion from int to EMC_TASK_SET_STATE" warning. You have to use > type > > > conversion to get rid of warning (EMC_TASK_SET_STATE)malloc(...) and > make > > > sure correct size is allocated by using sizof(...) and you also have to > > > remember deallocate/free memory then not used anymore but not before. > > > > > > > > > > > > > > > > > > > > > > > > > Memory may be allocated with malloc but unless function > > > > > emcCommandBuffer->write(...) store the pointer internally, copy > data > > > > > internally is below might be a much better idea. If state_msg > variable > > > is > > > > > not used further down or at least is not supposed the block will > also > > > limit > > > > > life time of variable. > > > > > > > > > > > > > this row of code is extract from shcom.cc: > > > > > > > > int emcCommandSend(RCS_CMD_MSG & cmd) > > > > { > > > > // write command > > > > if (emcCommandBuffer->write(&cmd)) { > > > > return -1; > > > > } > > > > emcCommandSerialNumber = cmd.serial_number; > > > > return 0; > > > > } > > > > > > > > int sendEstop() > > > > { > > > > EMC_TASK_SET_STATE state_msg; > > > > > > > > state_msg.state = EMC_TASK_STATE_ESTOP; > > > > emcCommandSend(state_msg); > > > > if (emcWaitType == EMC_WAIT_RECEIVED) { > > > > return emcCommandWaitReceived(); > > > > } else if (emcWaitType == EMC_WAIT_DONE) { > > > > return emcCommandWaitDone(); > > > > } > > > > > > > > return 0; > > > > } > > > > > > > > but there is not malloc for state_msg and not see where is > initialized > > > .... > > > > > > > > In my row code is the same situation .... but if try to use malloc > obtain > > > > warning like "no viable conversion from int to EMC_TASK_SET_STATE" > .... > > > is > > > > because I try to use malloc with bad variable type? > > > > In my QtDro.h file I use these .hh file of Lcnc: > > > > > > > > #include "include/cmd_msg.hh" > > > > #include "include/stat_msg.hh" > > > > #include "include/emc_nml.hh" > > > > #include <stat_msg.hh> > > > > #include <cmd_msg.hh> > > > > #include <nml.hh> > > > > #include "emc.hh" // EMC NML > > > > #include "include/emcglb.h" // EMC_NMLFILE, > > > TRAJ_MAX_VELOCITY, > > > > TOOL_TABLE_FILE > > > > #include "include/emccfg.h" // DEFAULT_TRAJ_MAX_VELOCITY > > > > #include "inifile.hh" // INIFILE > > > > > > > > Not understand how to initialize state_msg. > > > > > > > > thanks and good end of 2019 and new 2020 at all. > > > > > > > > bkt > > > > > > > > Il giorno gio 19 dic 2019 alle ore 17:54 N < > nicklas.karlsso...@gmail.com > > > > > > > > ha scritto: > > > > > > > > > > just a guess. > > > > > > > > > > > > EMC_TASK_SET_STATE *state_msg; > > > > > > > > > > > > state_msg is a pointer, yet no memory allocated for it. > > > > > > > > > > > > state_msg->state = EMC_TASK_STATE_OFF; > > > > > > > > > > > > you try to write in a memory space that officially has no memory > > > > > assigned yet. > > > > > > > > > > > > ju > > > > > You are correct no memory assigned. Maybe no warning for using an > > > > > unitialized variable, if turned a warning would be issued for using > > > > > unitizialized variable. > > > > > > > > > > Memory may be allocated with malloc but unless function > > > > > emcCommandBuffer->write(...) store the pointer internally, copy > data > > > > > internally is below might be a much better idea. If state_msg > variable > > > is > > > > > not used further down or at least is not supposed the block will > also > > > limit > > > > > life time of variable. > > > > > > > > > > { > > > > > EMC_TASK_SET_STATE state_msg; > > > > > > > > > > state_msg.state = EMC_TASK_STATE_OFF; > > > > > state_msg.serial_number = ++emcCommandSerialNumber; > > > > > emcCommandBuffer->write(&state_msg); > > > > > } > > > > > > > > > > > > > > > _______________________________________________ > > > > > Emc-developers mailing list > > > > > Emc-developers@lists.sourceforge.net > > > > > https://lists.sourceforge.net/lists/listinfo/emc-developers > > > > > > > > > > > > > _______________________________________________ > > > > Emc-developers mailing list > > > > Emc-developers@lists.sourceforge.net > > > > https://lists.sourceforge.net/lists/listinfo/emc-developers > > > > > > > > > -- > > > N <nicklas.karlsso...@gmail.com> > > > > > > > > > _______________________________________________ > > > Emc-developers mailing list > > > Emc-developers@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/emc-developers > > > > > > > _______________________________________________ > > Emc-developers mailing list > > Emc-developers@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/emc-developers > > > _______________________________________________ > Emc-developers mailing list > Emc-developers@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/emc-developers > _______________________________________________ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers