-
Notifications
You must be signed in to change notification settings - Fork 140
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
[FIXED] C++ compiler errors #832
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ac42801
[FIXED] C++ compiler errors
mtmk f1f3b9d
Fixing build removed check_cpp.cpp
mtmk 1a2b235
Added check_cpp build
mtmk 4c8f3d7
Moved rest of the inner structs
mtmk f21fd51
Fixed Windows build
mtmk 47b10bb
Fixing build and format
mtmk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
if(NOT BUILD_TESTING) | ||
return() | ||
endif() | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are failures on Travis for clang with sanitize. Not exactly sure why. So maybe try to build statically, so add this to this make file. |
||
if(NOT NATS_BUILD_LIB_STATIC) | ||
MESSAGE(FATAL_ERROR | ||
"Building tests require static library, or run CMake with -DBUILD_TESTING=OFF") | ||
return() | ||
endif() | ||
|
||
if(MSVC) | ||
set_source_files_properties(test.c PROPERTIES COMPILE_FLAGS "/w") | ||
endif() | ||
|
||
# We need this to build the test program | ||
include_directories(${PROJECT_SOURCE_DIR}/src) | ||
|
||
if(NATS_BUILD_WITH_TLS) | ||
include_directories(${OPENSSL_INCLUDE_DIR}) | ||
endif(NATS_BUILD_WITH_TLS) | ||
|
||
# Build the test program | ||
add_executable(check_cpp check_cpp.cpp) | ||
|
||
target_link_libraries(check_cpp nats_static ${NATS_EXTRA_LIB}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2017-2025 The NATS Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <iostream> | ||
#include <nats.h> | ||
|
||
// Check C++ compiler compatibility of structs in | ||
// natsp.h to avoid incomplete type errors such as C2079. | ||
#include <natsp.h> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
// jsOptionsPullSubscribeAsync opts should be accessible | ||
jsFetch fetch; | ||
fetch.opts.Timeout = 1; | ||
|
||
std::cout << "OK" << std::endl; | ||
return 0; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no issue making the
jsOptionsPullSubscribeAsync
a typedef structure, instead of being "embedded" injsOpts
, but if the issue is only because a user tries to includenatsp.h
, then I would not consider changing anything.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I think that is the case. do you think moving to typedefs is still worth while for future proofing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point no (seeing all the build failures).
At the very least, what you could do is update the PR by removing the cpp file and changes to examples' make file. Keep the changes in nats.h. Assuming there is no build issue, this PR should still be updated because then we would need to require a new version here because the header is changed.
If there is still build failures, have a new branch that is just pointing to main and push to see if CI still has build issues. If not, then let's close this PR. If there is still build issues, they may be temporary and I would feel better wait for those issues to be resolved with the main branch before trying to include this modified PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We got into the current state because we include
natsp.h
because we wrote our own watcher around thekvWatcher
. We did that so we could invoke a callback on the data. This is all before I got here. I will be looking into the NATS API around this private data structure as soon as I post this, so I haven't yet looked at the API as it exists. Is there an API that would invoke a callback per message that we either missed, or you added after this implementation?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok removed the cpp and reverted cmake. build seems fine now apart from couple of flappers presumably.
edit: should I move rest of the nested definitions for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mtmk Then we should still update the main make file as I mentioned earlier. That being said, it could be done as part of the next release. Also, we need to make sure that this PR does not end-up in the patch release. @levb can confirm.
Also, @PhilBarila does that mean that you are using other internals? That would not be too good, but regardless, if the change in this PR is enough to "fix" your issue, then fine.
In that case, @mtmk, the check.cpp may instead be in the test directory. It could be a subdirectory, similar to this. It would also need to be added to the tests to run like we do it here.
If this is confusing, I could do that as a separate PR later. Let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
kvWatcher
is the only thing we used from thenatsp.h
. If you have an alternative to writing our own jet-stream watcher, we'll take a very serious look at it ...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PhilBarila, you can create a watcher, but they are sync by nature, so you need to call their "next" API. I am not sure what you did exactly using the internal structure, so it is difficult for me to say if there is equivalent or not (if it is just to be a callback instead of a sync call, it sounds like a thread calling kvWatcher_Next() and invoking your callback with the result may be enough)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And pull the data out of it with
kvEntry_Value
... I'll have to do more digging, but that might work. I am only just wading in, so there's lots more to learn before we have a clean path forward to stop depending on your private data ... But we'll get it done as soon as is practical with all the other competing priorities ...