C
Charles Mills
Just wondering if there is a system as to which global variables are
Arrays and which are Strings.
For example $objs and $defs are Arrays and $LOCAL_LIBS, $libs and $LIBS
are all Strings.
I end up redefining $LOCAL_LIBS as an Array so I can do things like:
def local_lib_rules()
str = "\n"
$LOCAL_LIBS.each do |lib|
dir = File.dirname(lib)
str << lib << ":\n"
str << "\tcd #{dir} && $(MAKE)\n"
end
str << "\n"
end
# ....
# but then have to
$LOCAL_LIBS = $LOCAL_LIBS.join(' ')
# later in my code.
Also I have been using this function to determine the byte order,
perhaps it would be useful to somebody.
def check_byte_order(headers = nil, opt = "", &b)
message "checking byte order... "
src = %{#{COMMON_HEADERS}
#{headers}
#include <stdio.h>
/*top*/
int
main(void)
{
long a = 1;
if (*(char*)&a == 1)
printf("1234\\n");
else
printf("4321\\n");
return 0;
}
}
order = nil
if try_link0(src, opt, &b)
xpopen("./conftest") do |f|
order = f.gets
end
message "#{order}"
else
message "error\n"
exit 1
end
order
end
-Charlie
Arrays and which are Strings.
For example $objs and $defs are Arrays and $LOCAL_LIBS, $libs and $LIBS
are all Strings.
I end up redefining $LOCAL_LIBS as an Array so I can do things like:
def local_lib_rules()
str = "\n"
$LOCAL_LIBS.each do |lib|
dir = File.dirname(lib)
str << lib << ":\n"
str << "\tcd #{dir} && $(MAKE)\n"
end
str << "\n"
end
# ....
# but then have to
$LOCAL_LIBS = $LOCAL_LIBS.join(' ')
# later in my code.
Also I have been using this function to determine the byte order,
perhaps it would be useful to somebody.
def check_byte_order(headers = nil, opt = "", &b)
message "checking byte order... "
src = %{#{COMMON_HEADERS}
#{headers}
#include <stdio.h>
/*top*/
int
main(void)
{
long a = 1;
if (*(char*)&a == 1)
printf("1234\\n");
else
printf("4321\\n");
return 0;
}
}
order = nil
if try_link0(src, opt, &b)
xpopen("./conftest") do |f|
order = f.gets
end
message "#{order}"
else
message "error\n"
exit 1
end
order
end
-Charlie