Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7896575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:55:46+00:00 2026-06-03T07:55:46+00:00

I’m currently trying to compile a PHP driver for MongoDB using Visual Studio 2008

  • 0

I’m currently trying to compile a PHP driver for MongoDB using Visual Studio 2008 and I’m facing some problems with the compilation process.

Every time I try to build the project, the compiler keeps throwing me errors like these:

...\mongo_php_driver\bson.h(50) : error C2143: syntax error : missing ')' before '*'
...\mongo_php_driver\bson.h(50) : error C2143: syntax error : missing '{' before '*'
...\mongo_php_driver\bson.h(50) : error C2059: syntax error : 'type'
...\mongo_php_driver\bson.h(50) : error C2059: syntax error : ')'
...\mongo_php_driver\bson.h(53) : error C2143: syntax error : missing ')' before '*'
...\mongo_php_driver\bson.h(53) : error C2143: syntax error : missing '{' before '*'
...\mongo_php_driver\bson.h(53) : error C2059: syntax error : ','
...\mongo_php_driver\bson.h(53) : error C2059: syntax error : ')'
...\mongo_php_driver\bson.h(56) : error C2143: syntax error : missing ')' before '*'
...\mongo_php_driver\bson.h(56) : error C2143: syntax error : missing '{' before '*'
...\mongo_php_driver\bson.h(56) : error C2059: syntax error : ','
...\mongo_php_driver\bson.h(56) : error C2059: syntax error : ')'

There are about 740 of these and all of these errors are inside the header files. From what it says, I can understand that there are lots of syntax errors, but what I don’t understand is, the syntax looks just fine to me. I don’t know C very well, so I’m probably wrong on this though.

I thought the Visual Studio compiler is just acting up and throwing me fake errors, but I couldn’t find anything on Google about such issue. And in fact, I also tried to compile this with Code::Blocks only to find the same results. So there must be something really stupid that I forgot that causes these errors.

This is the content of bson.h as a reference (I’ve marked the line where the errors start):

/**
 *  Copyright 2009-2011 10gen, Inc.
 *
 *  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.
 */
#ifndef PHP_BSON_H
#define PHP_BSON_H 1


#define OID_SIZE 12

#define BSON_DOUBLE 1
#define BSON_STRING 2
#define BSON_OBJECT 3
#define BSON_ARRAY 4
#define BSON_BINARY 5
#define BSON_UNDEF 6
#define BSON_OID 7
#define BSON_BOOL 8
#define BSON_DATE 9
#define BSON_NULL 10
#define BSON_REGEX 11
#define BSON_DBREF 12
#define BSON_CODE__D 13
#define BSON_SYMBOL 14
#define BSON_CODE 15
#define BSON_INT 16
#define BSON_TIMESTAMP 17
#define BSON_LONG 18
#define BSON_MINKEY -1
#define BSON_MAXKEY 127

#define GROW_SLOWLY 1048576
#define INVALID_STRING_LEN(len) (len < 0 || len > (64*1024*1024))

#define CREATE_BUF_STATIC(n) char b[n];         \
  buf.start = buf.pos = b;                      \
  buf.end = b+n;


/*** Line 50 starts from here ***/
int php_mongo_serialize_size(char *start, buffer *buf TSRMLS_DC);

/* driver */
int php_mongo_serialize_element(char*, zval**, buffer*, int TSRMLS_DC);

/* objects */
void php_mongo_serialize_date(buffer*, zval* TSRMLS_DC);
void php_mongo_serialize_regex(buffer*, zval* TSRMLS_DC);
void php_mongo_serialize_code(buffer*, zval* TSRMLS_DC);
void php_mongo_serialize_ts(buffer*, zval* TSRMLS_DC);
void php_mongo_serialize_bin_data(buffer*, zval* TSRMLS_DC);
void php_mongo_serialize_int32(buffer*, zval* TSRMLS_DC);
void php_mongo_serialize_int64(buffer*, zval* TSRMLS_DC);

/* simple types */
void php_mongo_serialize_double(buffer*, double);
void php_mongo_serialize_string(buffer*, char*, int);
void php_mongo_serialize_long(buffer*, int64_t);
void php_mongo_serialize_int(buffer*, int);
void php_mongo_serialize_byte(buffer*, char);
void php_mongo_serialize_bytes(buffer*, char*, int);
void php_mongo_serialize_key(buffer*, char*, int, int TSRMLS_DC);
void php_mongo_serialize_ns(buffer*, char* TSRMLS_DC);

int php_mongo_write_insert(buffer*, char*, zval*, int max TSRMLS_DC);
int php_mongo_write_batch_insert(buffer*, char*, int flags, zval*, int max TSRMLS_DC);
int php_mongo_write_query(buffer*, mongo_cursor* TSRMLS_DC);
int php_mongo_write_get_more(buffer*, mongo_cursor* TSRMLS_DC);
int php_mongo_write_delete(buffer*, char*, int, zval* TSRMLS_DC);
int php_mongo_write_update(buffer*, char*, int, zval*, zval* TSRMLS_DC);
int php_mongo_write_kill_cursors(buffer*, int64_t TSRMLS_DC);

#define php_mongo_set_type(buf, type) php_mongo_serialize_byte(buf, (char)type)
#define php_mongo_serialize_null(buf) php_mongo_serialize_byte(buf, (char)0)
#define php_mongo_serialize_bool(buf, b) php_mongo_serialize_byte(buf, (char)b)

int resize_buf(buffer*, int);

int zval_to_bson(buffer*, HashTable*, int TSRMLS_DC);
char* bson_to_zval(char*, HashTable* TSRMLS_DC);

/**
 * Initialize buffer to contain "\0", so mongo_buf_append will start appending
 * at the beginning.
 */
void mongo_buf_init(char *dest);

/**
 * Takes a buffer and a string to add to the buffer.  The buffer must be large
 * enough to append the string and the string must be null-terminated. This will
 * not work for strings containing null characters (e.g., BSON).
 */
void mongo_buf_append(char *dest, char *piece);

#if PHP_C_BIGENDIAN
// reverse the bytes in an int
// wheeee stupid byte tricks
#define BYTE1_32(b) ((b & 0xff000000) >> 24)
#define BYTE2_32(b) ((b & 0x00ff0000) >> 8)
#define BYTE3_32(b) ((b & 0x0000ff00) << 8)
#define BYTE4_32(b) ((b & 0x000000ff) << 24)
#define MONGO_32(b) (BYTE4_32(b) | BYTE3_32(b) | BYTE2_32(b) | BYTE1_32(b))

#define BYTE1_64(b) ((b & 0xff00000000000000ll) >> 56)
#define BYTE2_64(b) ((b & 0x00ff000000000000ll) >> 40)
#define BYTE3_64(b) ((b & 0x0000ff0000000000ll) >> 24)
#define BYTE4_64(b) ((b & 0x000000ff00000000ll) >> 8)
#define BYTE5_64(b) ((b & 0x00000000ff000000ll) << 8)
#define BYTE6_64(b) ((b & 0x0000000000ff0000ll) << 24)
#define BYTE7_64(b) ((b & 0x000000000000ff00ll) << 40)
#define BYTE8_64(b) ((b & 0x00000000000000ffll) << 56)
#define MONGO_64(b) (BYTE8_64(b) | BYTE7_64(b) | BYTE6_64(b) | BYTE5_64(b) | BYTE4_64(b) | BYTE3_64(b) | BYTE2_64(b) | BYTE1_64(b))

#else
#define MONGO_32(b) (b)
#define MONGO_64(b) (b)
#endif

#endif
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:55:48+00:00Added an answer on June 3, 2026 at 7:55 am

    Your errors come because the compiler doesn’t know what “buffer” means. It’s defined in php_mongo.h. This implies that you’ve set-up your project wrong and tried to compile bson.h stand-alone.

    PHP extensions are not build with Visual Studio projects but through a specially written build system. You need to follow the instructions at https://wiki.php.net/internals/windows/stepbystepbuild

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.