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

Compile errors on windows due to changes in nii_dicom_batch.cpp #288

Closed
ljod opened this issue Apr 9, 2019 · 10 comments
Closed

Compile errors on windows due to changes in nii_dicom_batch.cpp #288

ljod opened this issue Apr 9, 2019 · 10 comments

Comments

@ljod
Copy link

ljod commented Apr 9, 2019

Hi and thank you very much for the recently added nrrd support! We have found that it doesn't yet compile on Windows (in the context of Slicer nightly multi-platform builds that are building dcm2niix) due to some minor issues with abs (needs to be changed to fabs) and getline (could be fixed by updating the code to use istream::getline instead). The needed fixes and the errors are described here:

https://discourse.slicer.org/t/slicerdcm2nii-extension-not-visible-in-extension-manager-despite-successful-build/6435/2

I don't have a Windows machine so I'm posting this here in the hopes that these minor changes are really easy for someone else. Thanks!!!

@neurolabusc
Copy link
Collaborator

@fedorov can you provide some input here. The getline call supports a feature you requested but I do not think anyone uses. In order to support many Windows builds, the simple fix is to add a dependency to iostream. At the moment, iostream is only required if the user compiles with CharLS support (and CharLS also requires C++14).

I prefer to have the minimum number of dependencies for the basic build. @fedorov would you mind if your feature request 252 is included as a compile time option (e.g. -DmyTextFileInputLists)? We could re-evaluate in the future if someone decides to support this feature.

By the way, these platform-dependent issues will be caught be AppVeyor when we move this from the developmental branch to the master. Once @fedorov responds, I think we can push a new master stable release.

@fedorov
Copy link

fedorov commented Apr 10, 2019

@fedorov would you mind if your feature request 252 is included as a compile time option (e.g. -DmyTextFileInputLists)?

No, I would not mind. The motivation for that feature was to support the use of dcm2niix as a Slicer DICOM plugin. Currently, the extension @ljod mentioned does not provide a plugin interface, but it does compile dcm2niix, so this option could be added at compile time. At some point I was planning to contribute the DICOM plugin interface to that extension.

@ljod
Copy link
Author

ljod commented Apr 10, 2019

This all sounds good to me thank you both!

neurolabusc added a commit that referenced this issue Apr 10, 2019
@neurolabusc
Copy link
Collaborator

@ljod and @tashrifbillah - can you test the latest commit on the developmental branch with the Slicer Windows build system. The iostream getline() function looks pretty different from the stdio getline() function I was using. In the latest commit I use fgets() instead of getline(), which works in my Unix environment. It looks like fgets() is also included in (Visual Studio)[https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fgets-fgetws?view=vs-2019] so I am cautiously optimistic.

If my latest commit does not compile with your compiler chain, remove the line:

#define myTextFileInputLists //comment out to disable this feature: https://github.com/rordenlab/dcm2niix/issues/288

and it should compile (albeit without the functionality that @fedorov requested).

@ljod
Copy link
Author

ljod commented Apr 10, 2019

Thank you! I think this will be automatically tested tonight by our build system. I'll give you an update here tomorrow.

@tashrifbillah
Copy link
Contributor

@ljod , I think the build went fine as per the errors were concerned.

However, taking a closer look at the warnings, I am not sure why warning C4804: '>': unsafe use of type 'bool' in operation is reported. Again, warning C4146: unary minus operator applied to unsigned type, result still unsigned should not hurt.

However, warning C4700: uninitialized local variable 'dti4D' used might be a real warning having dti4D uninitialized. Although a quick fix is to initialize dti4D to an empty float, may be @neurolabusc wants to make sure the warning is legit.

@neurolabusc
Copy link
Collaborator

@tashrifbillah the 'uninitialized local variable' reflects that you can not overload C functions. The warning is generated by this line, where the 0 flags that the dti4D structure is not populated.
return nii_saveNRRD(niiFilename, hdr, im, opts, d, &dti4D, 0);

I added a commit that might silence some of these warnings. However, the line numbers in the warnings do not correspond with line numbers shown on Github. Feel free to submit a pull request for the other warnings.

Note that g++ and clang++ both compile without these warnings. @ningfei built the dcm2niix superbuild script and knows much more than me about MSVC. He previously noted These are all due to MSVC's poor support of the C/C++ standard. So I think it might be better that we stick with VS 2015 and don't add support for older MSVC compiler.

@ljod
Copy link
Author

ljod commented Apr 11, 2019

@neurolabusc thanks this is excellent! Please let us know when to switch from the development branch to the main branch.

@neurolabusc
Copy link
Collaborator

See new stable release (v1.0.20190410). Now that NRRD is embedded I would suggest building off the stable master branch rather than the developmental branch.

@ljod
Copy link
Author

ljod commented Apr 12, 2019

Thank you very much!

yarikoptic added a commit to neurodebian/dcm2niix that referenced this issue May 6, 2020
* tag 'v1.0.20190410': (52 commits)
  Update dcm_qa submodule.
  Prevent MSVC compilation warnings
  Siemens PASL 3D BIDS tags (http://adni.loni.usc.edu/wp-content/uploads/2010/05/ADNI3_Basic_Siemens_Skyra_E11.pdf)
  Reduce Microsoft Visual Studio 14 warnings (rordenlab#288)
  Use fgets not getline (rordenlab#288)
  Fixes (rordenlab#286; rordenlab#287)
  Added missing space (coding standard).
  Supported dicom tag Accession Number (0008,0050). Struct TDICOMdata extended with accessionNumber property, modified dicom loader and supported exporting accession number into json file and using it as filename with %g modifier.
  Terminate when corrupted DICOM detected (rordenlab#283)
  Keep more characters for institution address (VR is ST)
  "dcm2niix -v" returns version (rordenlab#280)
  NRRD export supports oldmin/oldmax (http://teem.sourceforge.net/nrrd/format.html#oldmin)
  Assume 1.2.840.10008.1.2 if transfer syntax is empty
  Option to modify overwrite behavior (rordenlab#276)
  XA11 classic DICOM uses private tags for DWI (rordenlab#274)
  Detect Philips when manufacturer (0008,0070) has been erased (rordenlab#267)
  Detect discrepancies in PAR/REC slice thicknesses (rordenlab#273)
  New "-x i" option (https://www.nitrc.org/forum/forum.php?thread_id=9324&forum_id=4703)
  bvecs for Philips DWI using  0019,10bb, 0019,10bc
  Adjust negative MosaicRefAcqTimes (rordenlab#271)
  ...
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

4 participants