Skip to content
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

Issue to build the actual code with MSYS2 / MINGW64 related to usleep (Impact multiple files SignalGeneratorOscilloscope.cpp...) #262

Closed
bvernoux opened this issue Sep 22, 2020 · 2 comments

Comments

@bvernoux
Copy link
Contributor

Issue to build the actual code with MSYS2 / MINGW64 related to SignalGeneratorOscilloscope.cpp code
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
...
Error

[ 32%] Building CXX object lib/scopehal/CMakeFiles/scopehal.dir/RohdeSchwarzHMC8012Multimeter.cpp.obj
C:\msys64\home\Ben\scopehal-apps\lib\scopehal\SignalGeneratorOscilloscope.cpp: In member function 'virtual bool SignalGeneratorOscilloscope::AcquireData()':
C:\msys64\home\Ben\scopehal-apps\lib\scopehal\SignalGeneratorOscilloscope.cpp:120:2: error: 'usleep' was not declared in this scope; did you mean 'Glib::usleep'?
  120 |  usleep(40 * 1000);
      |  ^~~~~~
      |  Glib::usleep
In file included from C:/msys64/mingw64/include/glibmm-2.4/glibmm.h:143,
                 from C:/msys64/mingw64/include/gtkmm-3.0/gtkmm.h:87,
                 from C:/msys64/home/Ben/scopehal-apps/lib/graphwidget/Graph.h:39,
                 from C:\msys64\home\Ben\scopehal-apps\lib\scopehal\scopehal.h:50,
                 from C:\msys64\home\Ben\scopehal-apps\lib\scopehal\SignalGeneratorOscilloscope.cpp:36:
C:/msys64/mingw64/include/glibmm-2.4/glibmm/timer.h:72:6: note: 'Glib::usleep' declared here
   72 | void usleep(unsigned long microseconds);
      |      ^~~~~~
mingw32-make[2]: *** [lib\scopehal\CMakeFiles\scopehal.dir\build.make:601: lib/scopehal/CMakeFiles/scopehal.dir/SignalGeneratorOscilloscope.cpp.obj] Error 1
mingw32-make[2]: *** Waiting for unfinished jobs....
mingw32-make[1]: *** [CMakeFiles\Makefile2:251: lib/scopehal/CMakeFiles/scopehal.dir/all] Error 2
mingw32-make: *** [Makefile:149: all] Error 2

Issue is related to usleep() which is deprecated since POSIX.1-2001 Issue 6 and not supported by MinGW
See https://sourceforge.net/p/mingw/mailman/message/33179314/
Potential solution for that https://gist.github.com/ngryman/6482577

@bvernoux bvernoux changed the title Issue to build the actual code with MSYS2 / MINGW64 related to SignalGeneratorOscilloscope.cpp Issue to build the actual code with MSYS2 / MINGW64 related to usleep (Impact multiple files SignalGeneratorOscilloscope.cpp...) Sep 22, 2020
@bvernoux
Copy link
Contributor Author

bvernoux commented Sep 22, 2020

usleep() refactor:

Fixed in commit 776cedd#diff-0d1d73e86403ed9f06e12735b9937cd4

  • scopehal-apps\lib\scopehal\Oscilloscope.cpp (1 hit)
    Line 152: usleep(10 * 1000);
  • scopehal-apps/lib/scopehal/SignalGeneratorOscilloscope.cpp (1 hit)
    Line 120: usleep(40 * 1000);
  • scopehal-apps/libscopehal/scopehal.h
    Added #include & #include

Fixed in commit ngscopeclient/scopehal-apps@7c86f3c#diff-6d16a51d05214165d81b1dc2762dbf61

  • scopehal-apps\src\examples\curvetrace\main.cpp (2 hits)
    Line 107: usleep(25 * 1000);
    Line 121: usleep(50 * 1000);

Fixed in commit ngscopeclient/scopehal-apps@356403c#diff-4ec02d16f1079c62f88c4c0659ecde10

  • scopehal-apps\src\examples\fgtest\main.cpp (1 hit)
    Line 87: usleep(1000 * 50);

Fixed in commit ngscopeclient/scopehal-apps@6e255eb#diff-c7b71288f79589e7de3a7fdc1e0ad952

  • scopehal-apps\src\glscopeclient\OscilloscopeWindow.cpp (1 hit)
    Line 792: usleep(1000 * 50);

@nshcat
Copy link
Collaborator

nshcat commented Sep 22, 2020

It is better to use std::this_thread::sleep_for(std::chrono::microseconds(..)) than the WinAPI stuff you mentioned, since it is cross-platform.

Feel free to do those changes and create a PR if you have the time.

bvernoux added a commit to bvernoux/scopehal that referenced this issue Sep 23, 2020
azonenberg added a commit that referenced this issue Sep 23, 2020
Replace usleep(..) by std::this_thread::sleep_for(std::chrono::microseconds(..)) see PR #262
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants