c++ - Mix C-string and fortran-string in one file -


i have 1 question mixing c-string , fortran-string in 1 file.

supposed playing name string fixed length 9, define length macro

#define name_len 9 

in .c file.

there existing fortran-function, let's name fortran_function(char* name)

now have call fortran function in c function, let's name

c_function(char name[]) {     fortran_function(name)  } 

now problem is, how should declare c_function signature?

c_function(char name[]) c_function(char name[name_len +1]) 

or

c_function(char name[name_len]) 

under situations, should use 9 name length or 10?

my understanding that, long passed null-terminated string 9 characters c_function, declaration correct. right?

any other concern should put here? potential bugs?

there's 1 more gotcha here, if remember correctly. fortran not use null-terminated strings; instead, pads right end of buffer 0x20 (space). so, if have access fortran source, modify function signature take length of passed-in string argument. otherwise, crash fortran side of code.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -