Does deleting the default value of function parameter still keep binary compatibility?

375 views Asked by At

I'm now debugging code but need to keep binary compatibility. There now is a modification about the default value of function parameter.

void functionName(const type parameter = class::A::getValue());

Now I want to just change it like this :

void functionName(const type parameter);

Is it still binary compatibility?

1

There are 1 answers

2
TonyK On

Default parameters don't change the type of a function. gcc 4.9.1 compiles this code without warnings:

#include <iostream>
using namespace std;

static void f (int x) {
  cout << x << endl ;
}
static void g() ;

int main() {
  f (99) ;
  g() ;
  return 0 ;
}

static void f (int x = 101) ;

static void g() {
  f() ;
}

Re-declaring f to take a default parameter value is allowed here, which means that its linkage is unchanged. So you'll be OK.