Skip to content

Correction for issue #102 #110

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

Closed
wants to merge 3 commits into from
Closed

Correction for issue #102 #110

wants to merge 3 commits into from

Conversation

hlovdal
Copy link
Contributor

@hlovdal hlovdal commented Feb 3, 2019

Including Nullptr.h in Arduino.h breaks code that uses nullptr. The nullptr define in Nullptr.h is only applicable for use for the compare functions and should only be included when compiling the unit test files.

@ianfixes
Copy link
Collaborator

ianfixes commented Feb 4, 2019

I see what I was doing wrong. After some early experimentation, I had mis-read the error message and assumed that std::nullptr couldn't be exposed properly. I see now that it was a template issue combined with lack of an ostream operator.

I have different fix for this in https://github.com/ianfixes/arduino_ci/tree/2019-02-04_nullptr that I'm looking at now

@hlovdal
Copy link
Contributor Author

hlovdal commented Feb 5, 2019

Rename the file from cpp/unittest/OsteamHelpers.h to cpp/unittest/OstreamHelpers.h.

@hlovdal
Copy link
Contributor Author

hlovdal commented Feb 5, 2019

And one more fix:

    Add missing #include <ostream>

diff --git a/cpp/arduino/Godmode.cpp b/cpp/arduino/Godmode.cpp
index 424dad2..56692fd 100644
--- a/cpp/arduino/Godmode.cpp
+++ b/cpp/arduino/Godmode.cpp
@@ -1,3 +1,5 @@
+#include <ostream>
+
 #include "Godmode.h"
 #include "HardwareSerial.h"
 #include "SPI.h"
diff --git a/cpp/unittest/OstreamHelpers.h b/cpp/unittest/OstreamHelpers.h
index 4bf16c3..a2cd8f4 100644
--- a/cpp/unittest/OstreamHelpers.h
+++ b/cpp/unittest/OstreamHelpers.h
@@ -1,3 +1,5 @@
 #pragma once
 
+#include <ostream>
+
 inline std::ostream& operator << (std::ostream& out, const std::nullptr_t &np) { return out << "nullptr"; }

@ianfixes
Copy link
Collaborator

ianfixes commented Feb 5, 2019

Can you rebase this off latest master? I suspect the underlying issue has now been fixed. If (after merge) the tests I added in #112 still don't seem sufficient, I will be glad to merge this PR to add yours.

In file included from /usr/include/stdio.h:33,
                 from /usr/include/c++/8/cstdio:42,
                 from /usr/include/c++/8/ext/string_conversions.h:43,
                 from /usr/include/c++/8/bits/basic_string.h:6400,
                 from /usr/include/c++/8/string:52,
                 from /usr/include/c++/8/stdexcept:39,
                 from .../arduino_ci/cpp/arduino/WString.h:4,
                 from .../arduino_ci/cpp/arduino/Arduino.h:13,
                 from .../arduino_ci/SampleProjects/DoSomething/do-something.cpp:1:
.../arduino_ci/SampleProjects/DoSomething/do-something.cpp: In function ‘const something* findSomething(int)’:
.../arduino_ci/cpp/arduino/Nullptr.h:5:31: error: invalid conversion from ‘my_nullptr_t’ {aka ‘void*’} to ‘const something*’ [-fpermissive]
 #define nullptr (my_nullptr_t)NULL
                               ^~~~
.../arduino_ci/SampleProjects/DoSomething/do-something.cpp:20:9: note: in expansion of macro ‘nullptr’
  return nullptr;
         ^~~~~~~
@hlovdal
Copy link
Contributor Author

hlovdal commented Feb 5, 2019

Works fine after rebase. You might want to cherry-pick the readme commit.

@ianfixes
Copy link
Collaborator

ianfixes commented Feb 6, 2019

Awesome, I will incorporate that README.

@ianfixes ianfixes closed this Feb 6, 2019
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

Successfully merging this pull request may close these issues.

2 participants