Skip to content

Commit 338b7fb

Browse files
committed
CXX-277 Include windows headers where required
1 parent 330e75f commit 338b7fb

15 files changed

+122
-12
lines changed

src/mongo/bson/bsondemo/bsondemo.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
Windows: project files are available in this directory for bsondemo.cpp for use with Visual Studio.
3131
*/
3232

33+
// It is the responsibility of the mongo client consumer to ensure that any necessary windows
34+
// headers have already been included before including the driver facade headers.
35+
#if defined(_WIN32)
36+
#include <winsock2.h>
37+
#include <windows.h>
38+
#endif
39+
3340
#include "mongo/client/dbclient.h"
3441

3542
#include <iostream>

src/mongo/client/examples/arrayExample.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,19 @@
1313
* limitations under the License.
1414
*/
1515

16+
// It is the responsibility of the mongo client consumer to ensure that any necessary windows
17+
// headers have already been included before including the driver facade headers.
18+
#if defined(_WIN32)
19+
#include <winsock2.h>
20+
#include <windows.h>
21+
#endif
22+
23+
#include "mongo/bson/bson.h"
1624

1725
#include <iostream>
1826
#include <list>
1927
#include <vector>
20-
#include "mongo/bson/bson.h"
28+
2129

2230
using mongo::BSONArray;
2331
using mongo::BSONArrayBuilder;

src/mongo/client/examples/authTest.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@
1515
* limitations under the License.
1616
*/
1717

18+
// It is the responsibility of the mongo client consumer to ensure that any necessary windows
19+
// headers have already been included before including the driver facade headers.
20+
#if defined(_WIN32)
21+
#include <winsock2.h>
22+
#include <windows.h>
23+
#endif
24+
25+
#include "mongo/client/dbclient.h"
26+
1827
#include <boost/scoped_ptr.hpp>
1928
#include <iostream>
2029
#include <cstdlib>
2130
#include <string>
22-
#include "mongo/client/dbclient.h"
2331

2432
using namespace mongo;
2533

src/mongo/client/examples/clientTest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
* a simple test for the c++ driver
2020
*/
2121

22+
// It is the responsibility of the mongo client consumer to ensure that any necessary windows
23+
// headers have already been included before including the driver facade headers.
24+
#if defined(_WIN32)
25+
#include <winsock2.h>
26+
#include <windows.h>
27+
#endif
28+
2229
// this header should be first to ensure that it includes cleanly in any context
2330
#include "mongo/client/dbclient.h"
2431

src/mongo/client/examples/first.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@
1919
* this is a good first example of how to use mongo from c++
2020
*/
2121

22-
#include <iostream>
23-
#include <cstdlib>
22+
// It is the responsibility of the mongo client consumer to ensure that any necessary windows
23+
// headers have already been included before including the driver facade headers.
24+
#if defined(_WIN32)
25+
#include <winsock2.h>
26+
#include <windows.h>
27+
#endif
2428

2529
#include "mongo/client/dbclient.h"
2630

31+
#include <iostream>
32+
#include <cstdlib>
33+
2734
using namespace std;
2835

2936
void insert( mongo::DBClientConnection & conn , const char * name , int num ) {

src/mongo/client/examples/httpClientTest.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include <iostream>
18+
// It is the responsibility of the mongo client consumer to ensure that any necessary windows
19+
// headers have already been included before including the driver facade headers.
20+
#if defined(_WIN32)
21+
#include <winsock2.h>
22+
#include <windows.h>
23+
#endif
1924

2025
#include "mongo/client/dbclient.h"
2126
#include "mongo/util/net/httpclient.h"
2227

28+
#include <iostream>
29+
2330
#ifndef verify
2431
# define verify(x) MONGO_verify(x)
2532
#endif

src/mongo/client/examples/insert_demo.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@
1313
* limitations under the License.
1414
*/
1515

16-
#include <iostream>
16+
// It is the responsibility of the mongo client consumer to ensure that any necessary windows
17+
// headers have already been included before including the driver facade headers.
18+
#if defined(_WIN32)
19+
#include <winsock2.h>
20+
#include <windows.h>
21+
#endif
22+
1723
#include "mongo/client/dbclient.h" // the mongo c++ driver
1824

25+
#include <iostream>
26+
1927
using namespace std;
2028
using namespace mongo;
2129
using namespace bson;

src/mongo/client/examples/rs.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@
1919
* example of using replica sets from c++
2020
*/
2121

22+
// It is the responsibility of the mongo client consumer to ensure that any necessary windows
23+
// headers have already been included before including the driver facade headers.
24+
#if defined(_WIN32)
25+
#include <winsock2.h>
26+
#include <windows.h>
27+
#endif
28+
29+
#include "mongo/client/dbclient.h"
30+
2231
#include <iostream>
2332
#include <vector>
2433
#include <boost/thread/thread.hpp>
2534

26-
#include "mongo/client/dbclient.h"
27-
2835
using namespace mongo;
2936
using namespace std;
3037

src/mongo/client/examples/second.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include <iostream>
18+
// It is the responsibility of the mongo client consumer to ensure that any necessary windows
19+
// headers have already been included before including the driver facade headers.
20+
#if defined(_WIN32)
21+
#include <winsock2.h>
22+
#include <windows.h>
23+
#endif
1924

2025
#include "mongo/client/dbclient.h"
2126

27+
#include <iostream>
28+
2229
using namespace std;
2330
using namespace mongo;
2431

src/mongo/client/examples/simple_client_demo.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,17 @@
1515

1616
// See also : http://dochub.mongodb.org/core/cppdrivertutorial
1717

18-
#include <iostream>
18+
// It is the responsibility of the mongo client consumer to ensure that any necessary windows
19+
// headers have already been included before including the driver facade headers.
20+
#if defined(_WIN32)
21+
#include <winsock2.h>
22+
#include <windows.h>
23+
#endif
24+
1925
#include "mongo/client/dbclient.h" // the mongo c++ driver
2026

27+
#include <iostream>
28+
2129
using namespace std;
2230
using namespace mongo;
2331
using namespace bson;

0 commit comments

Comments
 (0)